Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expansion #707

Merged
merged 16 commits into from
Jun 9, 2023
Prev Previous commit
Next Next commit
implementing engineering wing
  • Loading branch information
Continuities committed Jun 5, 2023
commit 6a986c8893db8a9a635f11b052f984df4d71618b
28 changes: 22 additions & 6 deletions script/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,6 @@ var Events = {
if(Events.fought) {
return;
}
World.setHp(World.getMaxHealth());
Events.endFight();
// AudioEngine.playSound(AudioLibrary.WIN_FIGHT);
$('#enemy').animate({opacity: 0}, 300, 'linear', function() {
Expand Down Expand Up @@ -932,6 +931,17 @@ var Events = {
return (btnsList.length == 1) ? btnsList[0] : false;
},

getQuantity: function(store) {
if (store === 'water') {
return World.water;
}
if (store === 'hp') {
return World.health;
}
var num = Engine.activeModule == World ? Path.outfit[store] : $SM.get('stores["'+store+'"]', true);
if(typeof num != 'number') num = 0;
},

updateButtons: function() {
var btns = Events.activeEvent().scenes[Events.activeScene].buttons;
for(var bId in btns) {
Expand All @@ -942,8 +952,7 @@ var Events = {
} else if(b.cost) {
var disabled = false;
for(var store in b.cost) {
var num = Engine.activeModule == World ? Path.outfit[store] : $SM.get('stores["'+store+'"]', true);
if(typeof num != 'number') num = 0;
var num = Engine.getQuantity(store);
if(num < b.cost[store]) {
// Too expensive
disabled = true;
Expand All @@ -961,13 +970,20 @@ var Events = {
var costMod = {};
if(info.cost) {
for(var store in info.cost) {
var num = Engine.activeModule == World ? Path.outfit[store] : $SM.get('stores["'+store+'"]', true);
if(typeof num != 'number') num = 0;
var num = Engine.getQuantity(store);
if(num < info.cost[store]) {
// Too expensive
return;
}
costMod[store] = -info.cost[store];
if (store === 'water') {
World.setWater(World.water - info.cost[store]);
}
else if (store === 'hp') {
World.setHp(World.hp - info.cost[store]);
}
else {
costMod[store] = -info.cost[store];
}
}
if(Engine.activeModule == World) {
for(var k in costMod) {
Expand Down
Loading