Skip to content

Commit

Permalink
Merge branch 'master' of github.com:cracrayol/kaichronicles
Browse files Browse the repository at this point in the history
  • Loading branch information
cracrayol committed Aug 24, 2024
2 parents 4d41afb + bdd74eb commit cead285
Show file tree
Hide file tree
Showing 16 changed files with 2,855 additions and 39 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Kai Chronicles

[Kai Chronicles](https://kaichronicles.projectaon.org) is a game player for Lone Wolf game books. Books 1 - 25 are playable. The game player can run as a website.
[Kai Chronicles](https://kaichronicles.projectaon.org) is a game player for Lone Wolf game books. Books 1 - 26 are playable. The game player can run as a website.

This is a fork from the [original "Kai Chronicles"](https://github.com/tonib/kaichronicles) as tonib stopped development in November 2021.

Expand Down
4 changes: 3 additions & 1 deletion doc/README-objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Optional. If it's set, the object has some effect when it's carried:
* **"class" property**: It says what is the effect of the object:
* "endurance": The endurance will be increased
* "combatSkill": The combat skill will be increased
* "special": Objects with complex behavior. They are implemented on SpecialObjectsUse class, at specialObjectsUse.ts
* "backpackSlots": The number of backpack slots will be increased
* **"increment" property**: Amount to increment

### "incompatibleWith" property
Expand Down Expand Up @@ -163,9 +163,11 @@ If it's set, the player can "use" the object, and then it will be dropped from t
* "endurance": The endurance will be increased
* "combatSkill": The combat skill will be increased. This will apply only for the
current section
* "special": Objects with complex behavior. They are implemented on SpecialObjectsUse class, at specialObjectsUse.ts
* **"increment" property**: Amount to increment
* **"priorCombat" property**: If true and class is endurance, than can be used prior a combat (false by default)
* **"takenWithMeal" property**: If true, it can only be used if the player has a meal or Grand Huntmastery (meal will be consumed)
* **"takenWithLaumspur" property**: If true, it can only be used if the player has a Laumspur potion or Herbmastery (potion will be consumed)

### "isMeal" property
If true, the object can be eaten as a Meal.
Expand Down
6 changes: 4 additions & 2 deletions src/ts/controller/actionChartController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,10 @@ export const actionChartController = {
/**
* Use an object
* @param objectId The object to use
* @param dropObject True if the object should be droped from the action chart
* @param dropObject True if the object should be dropped from the action chart
* @param index If used object was a owned object, this is the object index in its Action Chart array. If not specified
* or < 0, the first owned object will be used
* @param displayToast True if a message must to be displayed
* @param displayToast True if a message must be displayed
*/
use(objectId: string, dropObject: boolean = true, index: number = -1, displayToast = false, applyEffect = true) {
// Get the object
Expand All @@ -315,6 +315,8 @@ export const actionChartController = {
// Check if a meal should be consumed as well (note that meal-like objects are not observed here, since New Order hasn't offered any yet)
if (o.usage.takenWithMeal && !state.actionChart.hasDiscipline(NewOrderDiscipline.GrandHuntmastery)) {
actionChartController.increaseMeals(-1);
} else if (o.usage.takenWithLaumspur && !state.actionChart.hasDiscipline(NewOrderDiscipline.Herbmastery)) {
actionChartController.use("laumspurpotion4");
}
} else if (o.usage.cls === Item.COMBATSKILL) {
// Combat skill modifiers only apply to the current section combats
Expand Down
39 changes: 32 additions & 7 deletions src/ts/model/actionChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export class ActionChart {
if ( !this.hasBackpack ) {
throw translations.text( "backpackLost" );
}
if ( ( this.getNBackpackItems(false) + item.itemCount ) > ActionChart.getMaxBackpackItems() ) {
if ( ( this.getNBackpackItems(false) + item.itemCount ) > this.getMaxBackpackItems() ) {
throw translations.text( "msgNoMoreBackpackItems" );
}
if ( aChartItem.id === Item.MEAL ) {
Expand All @@ -357,9 +357,9 @@ export class ActionChart {
}

/**
* Returns the total number of backpack items, according to the number of slots each item consum
* @param roundToInteger If true (default), the total number of objects will be rounded up to a integer (Item.itemCount can have decimals)
* @param useItemCount If true (default), use the valur of itemCount, otherwise each item count as 1.
* Returns the total number of backpack items, according to the number of slots each item consumes
* @param roundToInteger If true (default), the total number of objects will be rounded up to an integer (Item.itemCount can have decimals)
* @param useItemCount If true (default), use the value of itemCount, otherwise each item count as 1.
* @returns The number of objects on the backpack
*/
public getNBackpackItems(roundToInteger = true, useItemCount = true): number {
Expand Down Expand Up @@ -407,7 +407,7 @@ export class ActionChart {
throw translations.text("backpackLost");
}

const maxToPick = ActionChart.getMaxBackpackItems() - this.getNBackpackItems();
const maxToPick = this.getMaxBackpackItems() - this.getNBackpackItems();
if ( maxToPick < 0 ) {
count = 0;
} else if (count > maxToPick) {
Expand Down Expand Up @@ -1073,6 +1073,24 @@ export class ActionChart {
$.each(this.specialItems, enumerateFunction);
}

/**
* Get the current bonuses for backpack slots
* @returns Array of objects with the backpack slot bonuses
*/
public getBackpackSlotsBonuses(): Bonus[] {
const bonuses: Bonus[] = [];
this.enumerateObjectsAsItems((o: Item) => {
if (o.backpackSlotsBonusEffect) {
bonuses.push({
concept: o.name,
increment: o.backpackSlotsBonusEffect
});
}
});

return bonuses;
}

/**
* Get the current bonuses for endurance
* @return Array of objects with the bonuses concepts
Expand Down Expand Up @@ -1509,8 +1527,15 @@ export class ActionChart {
/**
* Return the maximum number of backpack items in the current book
*/
private static getMaxBackpackItems(): number {
return state.book.getBookSeries().id >= BookSeriesId.GrandMaster ? 10 : 8;
public getMaxBackpackItems(): number {
const bonuses = this.getBackpackSlotsBonuses();

let backpackSlots = state.book.getBookSeries().id >= BookSeriesId.GrandMaster ? 10 : 8;
for (const bonus of bonuses) {
backpackSlots += bonus.increment;
}

return backpackSlots;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/ts/model/bookSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class BookSeries {
new BookSeries(BookSeriesId.Kai, 1, 5, 5, KaiDiscipline.Weaponskill, 1, KaiDiscipline.Mindshield, 10, 20),
new BookSeries(BookSeriesId.Magnakai, 6, 12, 3, MgnDiscipline.Weaponmastery, 3, MgnDiscipline.PsiScreen, 10, 20),
new BookSeries(BookSeriesId.GrandMaster, 13, 20, 4, GndDiscipline.GrandWeaponmastery, 2, GndDiscipline.KaiScreen, 25, 30),
new BookSeries(BookSeriesId.NewOrder, 21, 25, 5, NewOrderDiscipline.GrandWeaponmastery, 1, NewOrderDiscipline.KaiScreen, 25, 30)
new BookSeries(BookSeriesId.NewOrder, 21, 26, 5, NewOrderDiscipline.GrandWeaponmastery, 1, NewOrderDiscipline.KaiScreen, 25, 30)
];

private constructor(id: BookSeriesId, bookStart: number, bookEnd: number, initialNDisciplines: number,
Expand Down
12 changes: 11 additions & 1 deletion src/ts/model/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export interface ItemEffect {

/** Usage requires and consumes meal */
takenWithMeal: boolean;

/** Usage requires and consumes meal */
takenWithLaumspur: boolean;
}

/**
Expand All @@ -26,6 +29,7 @@ export class Item {
// Item effect classes (see ItemEffect interface)
public static readonly COMBATSKILL = "combatSkill";
public static readonly ENDURANCE = "endurance";
public static readonly BACKPACKSLOTS = "backpackSlots";

// Object types
/** Special item type */
Expand Down Expand Up @@ -108,6 +112,9 @@ export class Item {
/** Endurance increment when the player carry the object */
public enduranceEffect: number = 0;

/** Number of extra backpack slots */
public backpackSlotsBonusEffect: number = 0;

/** Usage effect */
public usage: ItemEffect;

Expand Down Expand Up @@ -204,7 +211,8 @@ export class Item {
cls: $usage.attr("class"),
increment: parseInt($usage.attr("increment"), 10),
priorCombat: $usage.attr("priorCombat") === "true",
takenWithMeal: $usage.attr("takenWithMeal") === "true"
takenWithMeal: $usage.attr("takenWithMeal") === "true",
takenWithLaumspur: $usage.attr("takenWithLaumspur") === "true",
};
}

Expand All @@ -218,6 +226,8 @@ export class Item {
this.combatSkillEffect = increment;
} else if (cls === Item.ENDURANCE) {
this.enduranceEffect = increment;
} else if (cls === Item.BACKPACKSLOTS) {
this.backpackSlotsBonusEffect = increment;
} else {
mechanicsEngine.debugWarning("Object " + this.id + ", wrong class effect: " + cls);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ts/model/mechanics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class Mechanics {
}

/**
* Get a jquery selector for a give rule, relative to the "section" parent
* Get a jquery selector for a given rule, relative to the "section" parent
* @return {string} The jquery selector for the rule inside the section
*/
public static getRuleSelector(rule: Element): string {
Expand Down
8 changes: 8 additions & 0 deletions src/ts/model/projectAon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,14 @@ export const projectAon = {
illustrators: [ "williams" ],
biographies: [ "jdbiolw" , "bwbiolw" ]
},

// Book 26:
{
title: "The Fall Of Blood Mountain",
code: "26tfobm",
illustrators: [ "williams" ],
biographies: [ "jdbiolw" , "bwbiolw" ]
},
] as BookMetadata[],

/**
Expand Down
12 changes: 8 additions & 4 deletions src/ts/views/viewsUtils/objectsTableItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ export class ObjectsTableItem {
const count = ( this.objectInfo.count ? this.objectInfo.count : 0 );
// In INVENTORY always show "0 arrows", but not in SELL or AVAILABLE (ugly)
if ( count > 0 || this.type === ObjectsTableType.INVENTORY ) {
name += " (" + count.toFixed() + " " + translations.text("arrows") + ")";
name += " (" + count.toFixed() + " " + (count === 1 ? translations.text("arrow") : translations.text("arrows")) + ")";
}
}

// Arrow amount
if ( this.objectInfo.id === Item.ARROW && this.objectInfo.count ) {
name = this.objectInfo.count.toFixed() + " " + name;
name = this.objectInfo.count.toFixed() + " " + (this.objectInfo.count === 1 ? translations.text("arrow") : name);
}

// Fireseed amount
Expand Down Expand Up @@ -242,7 +242,8 @@ export class ObjectsTableItem {
const currentSection = state.sectionStates.getSectionState();
if (this.item.usage && (this.item.usage.cls !== Item.ENDURANCE || !currentSection.someCombatActive() ||
(this.item.usage.priorCombat && !currentSection.areCombatsStarted() && currentSection.areCombatsPotionsAllowed()))
&& (!this.item.usage.takenWithMeal || state.actionChart.meals > 0 || state.actionChart.hasDiscipline(NewOrderDiscipline.GrandHuntmastery))) {
&& (!this.item.usage.takenWithMeal || state.actionChart.meals > 0 || state.actionChart.hasDiscipline(NewOrderDiscipline.GrandHuntmastery))
&& (!this.item.usage.takenWithLaumspur || state.actionChart.hasObject("laumspurpotion4") || state.actionChart.hasDiscipline(NewOrderDiscipline.Herbmastery))) {
// Use object operation
html += this.getUseOperation();
}
Expand All @@ -253,7 +254,10 @@ export class ObjectsTableItem {
html += this.getOperationTag( "currentWeapon" , title , '<span class="glyphicon glyphicon-hand-left"></span>' );
}

if ( this.item.droppable ) {
// Prevent dropping the item if it gives bonus backpack slots and we would be over the limit after dropping
if ( this.item.droppable
&& (this.item.backpackSlotsBonusEffect === 0 ||
( state.actionChart.getNBackpackItems() <= state.actionChart.getMaxBackpackItems() - this.item.backpackSlotsBonusEffect + this.item.itemCount)) ) {
// Object can be dropped:
const title = translations.text("dropObject");
html += this.getOperationTag( "drop" , title , '<span class="glyphicon glyphicon-remove"></span>' );
Expand Down
9 changes: 5 additions & 4 deletions src/ts/views/viewsUtils/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class Translations {
"sheasutorq" : "Sheasu Torqs",
"orla" : "Orla",
"ain" : "Ain",
"arrow" : "Arrow",
"arrows" : "Arrows",
"current" : "Current",
"backpackLost" : "You have lost your backpack",
Expand All @@ -46,11 +47,11 @@ export class Translations {
"msgGetMeal" : "You got {0} meals",
"msgDropMeal" : "You drop {0} meals",
"msgGetMoney" : "You got {0} {1}",
"msgGetArrows" : "You got {0} arrows",
"msgGetArrow" : "You got {0} arrow",
"msgGetArrows" : "You got {0} Arrows",
"msgGetArrow" : "You got {0} Arrow",
"msgDropMoney" : "You lost {0} {1}",
"msgDropArrows" : "You lost {0} arrows",
"msgDropArrow" : "You lost {0} arrow",
"msgDropArrows" : "You lost {0} Arrows",
"msgDropArrow" : "You lost {0} Arrow",
"msgEndurance" : "{0} Endurance Points",
"msgCombatSkill" : "{0} Combat Skill",
"msgCurrentWeapon" : 'Your current weapon is now "{0}"',
Expand Down
5 changes: 2 additions & 3 deletions www/data/mechanics-22.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1690,9 +1690,8 @@
<choiceState section="sect317" set="enabled" />
</case>
</randomTable>
<test hasWeaponskillWith="bow">
<randomTableIncrement increment="+5" />
</test>
<randomTableIncrement increment="[BOWBONUS]" />

</section>

<section id="sect275">
Expand Down
15 changes: 5 additions & 10 deletions www/data/mechanics-25.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1283,9 +1283,7 @@
<choiceState section="sect317" set="enabled" />
</case>
</randomTable>
<test hasWeaponskillWith="bow">
<randomTableIncrement increment="5" />
</test>
<randomTableIncrement increment="[BOWBONUS]" />
</section>

<section id="sect162">
Expand Down Expand Up @@ -1563,9 +1561,8 @@
<choiceState section="sect317" set="enabled" />
</case>
</randomTable>
<test hasWeaponskillWith="bow">
<randomTableIncrement increment="5" />
</test>
<randomTableIncrement increment="[BOWBONUS]" />

</section>

<section id="sect199">
Expand Down Expand Up @@ -2084,9 +2081,8 @@
<choiceState section="sect280" set="enabled" />
</case>
</randomTable>
<test hasWeaponskillWith="bow">
<randomTableIncrement increment="5" />
</test>
<randomTableIncrement increment="[BOWBONUS]" />

</section>

<section id="sect273">
Expand Down Expand Up @@ -2638,7 +2634,6 @@
<section id="sect350">
<!-- Reset any disabled disciplines -->
<resetNewOrderDisabledDisciplines />
<message text="Congratulations! You have finished the last book of Kai Chronicles!" />
</section>
</sections>
</mechanics>
Loading

0 comments on commit cead285

Please sign in to comment.