Fix some smal bugs
This commit is contained in:
parent
7ae55ab377
commit
4a1d96a434
1 changed files with 13 additions and 7 deletions
20
src/main.js
20
src/main.js
|
@ -42,10 +42,6 @@ class Engine {
|
||||||
if (this.ship.docked_to instanceof Station) {
|
if (this.ship.docked_to instanceof Station) {
|
||||||
$('#asteroid').hide();
|
$('#asteroid').hide();
|
||||||
$('#station').show();
|
$('#station').show();
|
||||||
|
|
||||||
_.eachObj(this.ship.resources, (key, value) => {
|
|
||||||
$('#ship-inventory .res-' + key).set('@value', value);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.ship.docked_to instanceof Asteroid) {
|
if (this.ship.docked_to instanceof Asteroid) {
|
||||||
|
@ -65,13 +61,16 @@ class Ship {
|
||||||
|
|
||||||
this.equipment = {
|
this.equipment = {
|
||||||
'probe': station.inventory['probe']
|
'probe': station.inventory['probe']
|
||||||
|
};
|
||||||
|
this.upgrades = {
|
||||||
|
|
||||||
};
|
};
|
||||||
this.resources = {
|
this.resources = {
|
||||||
dust: 0,
|
dust: 0,
|
||||||
stone: 0,
|
stone: 0,
|
||||||
carbon: 0,
|
carbon: 0,
|
||||||
metal: 0
|
metal: 0
|
||||||
}
|
};
|
||||||
this.cbtc = 450;
|
this.cbtc = 450;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +158,7 @@ class Station {
|
||||||
}
|
}
|
||||||
|
|
||||||
sell(ship, tool) {
|
sell(ship, tool) {
|
||||||
// Tools can't be buy several times
|
// Tools can't be buy multiple times
|
||||||
if (!_.keys(this.inventory).contains(tool) ||
|
if (!_.keys(this.inventory).contains(tool) ||
|
||||||
_.keys(ship.equipment).contains(tool)) {
|
_.keys(ship.equipment).contains(tool)) {
|
||||||
alert('You already own this tool.');
|
alert('You already own this tool.');
|
||||||
|
@ -177,7 +176,7 @@ class Station {
|
||||||
}
|
}
|
||||||
|
|
||||||
buy(ship, resource, amount) {
|
buy(ship, resource, amount) {
|
||||||
if (ship.resources[resource] < amount) {
|
if (ship.resources[resource] < amount || amount < 0) {
|
||||||
alert('You have not enough resources loaded');
|
alert('You have not enough resources loaded');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -204,6 +203,13 @@ $(() => {
|
||||||
$('#btn-to-station').onClick(() => {
|
$('#btn-to-station').onClick(() => {
|
||||||
engine.ship.docked_to = engine.station;
|
engine.ship.docked_to = engine.station;
|
||||||
engine.current_asteroid = null;
|
engine.current_asteroid = null;
|
||||||
|
|
||||||
|
// Update the resources to sell. If the ship is docket to a station,
|
||||||
|
// the resources do not change because we can't mine.
|
||||||
|
_.eachObj(engine.ship.resources, (key, value) => {
|
||||||
|
$('#ship-inventory .res-' + key).set('value', value);
|
||||||
|
});
|
||||||
|
|
||||||
engine.update();
|
engine.update();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue