forked from tonib/kaichronicles
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from lonevvolf/book-28
Book 28
- Loading branch information
Showing
35 changed files
with
2,042 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/ts/controller/mechanics/specialSections/book28sect192.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { state, Combat, InventoryState, actionChartController, mechanicsEngine, gameController, ObjectsTableType, ObjectsTable, Mechanics } from "../../.."; | ||
|
||
/** | ||
* Generate trader with funny deals | ||
* This has an issue: | ||
* If you buy an item, then drop a special item, then drop the purchased item, then pick up the special item, the already purchased item will cost money | ||
*/ | ||
export const book28sect192 = { | ||
|
||
run() { | ||
const sectionState = state.sectionStates.getSectionState(); | ||
var itemPrice = 4; | ||
var refresh = false; | ||
const items = ["klorvapotion", "sabitoroot", "anduiflask"]; | ||
|
||
// If there is one item left with a price of 4, reduce it to 2 (total cost of 3 items will be 10) | ||
if (sectionState.objects.filter((o) => o.price > 0).length === 1) { | ||
itemPrice = 2; | ||
} | ||
|
||
// If there is a Special Item on the section, make the items free | ||
if (sectionState.getCntSectionObjects("special")) { | ||
itemPrice = 0; | ||
} | ||
|
||
// If the price has changed, update the objects and mark for refresh | ||
if (sectionState.objects && sectionState.objects.length && sectionState.objects[0].price != itemPrice) { | ||
items.forEach((itemToUpdate) => { | ||
if (sectionState.getSectionObjects().find((item) => item.id === itemToUpdate)) { | ||
let rule = $(`<object objectId="${itemToUpdate}" />`); | ||
delete sectionState.executedRules[ Mechanics.getRuleSelector(rule[0]) ]; | ||
sectionState.removeObjectFromSection(itemToUpdate, -1); | ||
refresh = true; | ||
} | ||
}); | ||
} | ||
|
||
// Add the objects to the available objects on the section | ||
items.forEach((itemToUpdate) => { | ||
let rule = $(`<object objectId="${itemToUpdate}" />`); | ||
// Do not execute the rule twice: | ||
if (!sectionState.ruleHasBeenExecuted(rule[0])) { | ||
sectionState.addObjectToSection(itemToUpdate, itemPrice); | ||
sectionState.markRuleAsExecuted(rule[0]); | ||
} | ||
}); | ||
|
||
// If there is a Special Item on the section, prevent pickup unless all the sale items are still there | ||
if (sectionState.objects && sectionState.objects.length | ||
&& sectionState.getCntSectionObjects("special") | ||
&& !(sectionState.objects.find((o) => o.id == "klorvapotion") | ||
&& sectionState.objects.find((o) => o.id == "sabitoroot") | ||
&& sectionState.objects.find((o) => o.id == "anduiflask"))) { | ||
const itemToDisable = sectionState.getSectionObjects("special")[0].id; | ||
$(`a[data-objectid='${itemToDisable}']`).attr('disabled', 'disabled'); | ||
} | ||
|
||
if (refresh) { | ||
gameController.loadSection(state.sectionStates.currentSection, false, | ||
window.pageYOffset); | ||
} | ||
} | ||
}; |
77 changes: 77 additions & 0 deletions
77
src/ts/controller/mechanics/specialSections/book28sect71.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { state, Combat, InventoryState, actionChartController } from "../../.."; | ||
|
||
/** | ||
* Generate combat against own Kai Weapon | ||
*/ | ||
export const book28sect71 = { | ||
|
||
run() { | ||
// Get stored Kai Weapon | ||
const restorePoint = "lostKaiWeapon"; | ||
const inventoryStateObject: any = state.sectionStates.otherStates[restorePoint]; | ||
const inventoryState = InventoryState.fromObject(inventoryStateObject); | ||
const kaiWeaponItem = inventoryState.specialItems[0]; | ||
const sectionState = state.sectionStates.getSectionState(); | ||
|
||
// If the combat has already been added | ||
if (sectionState.combats.length) { | ||
return; | ||
} | ||
|
||
const pageCombat = $(".combat"); | ||
var defaultCS = pageCombat.contents().filter(function() { | ||
return this.nodeType == 3; | ||
}).first().text(); | ||
var defaultEP = pageCombat.contents().filter(function() { | ||
return this.nodeType == 3; | ||
}).last().text(); | ||
|
||
var extractedCS = defaultCS.replace(/[^0-9]/gi, ''); // Replace everything that is not a number with nothing | ||
var extractedEP = defaultEP.replace(/[^0-9]/gi, ''); // Replace everything that is not a number with nothing | ||
var enemyCS = parseInt(extractedCS, 10); | ||
var enemyEP = parseInt(extractedEP, 10); | ||
|
||
// Adjust enemy CS by 5 less any damage to the weapon | ||
if (kaiWeaponItem) { | ||
enemyCS += 5 + kaiWeaponItem.damage; | ||
extractedCS += ` +${5 + kaiWeaponItem.damage} CS Kai Weapon Bonus`; | ||
|
||
// Adjust enemy CS for any bonuses | ||
if (kaiWeaponItem.id === "illuminatus") { | ||
enemyCS += 2; | ||
extractedCS += ` +2 CS Illuminatus`; | ||
} else if (kaiWeaponItem.id === "valiance" && | ||
(state.actionChart.hasDiscipline("alchemy") || state.actionChart.hasDiscipline("magi"))) { | ||
enemyCS += 3; | ||
extractedCS += ` +3 CS Valiance`; | ||
} else if (kaiWeaponItem.id === "kaistar") { | ||
enemyCS += 2; | ||
extractedCS += ` +2 CS Kaistar`; | ||
} | ||
} | ||
|
||
// Remove the existing combat from UI and state, to be replaced with a new one | ||
$(".combat").remove(); | ||
state.sectionStates.getSectionState().combats[0].combatSkill = enemyCS; | ||
|
||
$('#game-section > p.choice').before( | ||
`<div class="combat well"> | ||
<b>Tomb Robbers (with Kai Weapon)</b> | ||
<br> | ||
<span class="attribute"> | ||
COMBAT SKILL | ||
</span> | ||
: ${extractedCS} | ||
<span class="attribute"> | ||
ENDURANCE | ||
</span>: | ||
<span class="enemy-current-endurance"> | ||
${enemyEP} | ||
</span> | ||
/ ${enemyEP} | ||
</div>`); | ||
|
||
// Add combat to the section | ||
state.sectionStates.getSectionState().combats.push(new Combat("Tomb Robbers (with Kai Weapon)", enemyCS, enemyEP)); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.