Просмотр исходного кода

Add a way to recruit allies; fix self-selection bug in combat

Eating an ally would wind up causing both the left and right
selections to be yourself, which caused duplicate keys
and broke the interface. Pair actions are now only checked if
the left and right selections are distinct.
master
Fen Dweller 5 лет назад
Родитель
Сommit
3131e8889d
3 измененных файлов: 22 добавлений и 5 удалений
  1. +4
    -4
      src/components/Combat.vue
  2. +17
    -1
      src/game/maps/town.ts
  3. +1
    -0
      src/game/world.ts

+ 4
- 4
src/components/Combat.vue Просмотреть файл

@@ -21,8 +21,8 @@
<div v-if="encounter.currentMove === left" class="vert-display"> <div v-if="encounter.currentMove === left" class="vert-display">
<i class="action-label fas fa-users" v-if="left.validGroupActions(combatants).length > 0"></i> <i class="action-label fas fa-users" v-if="left.validGroupActions(combatants).length > 0"></i>
<ActionButton @described="described" @executed="executedLeft" v-for="(action, index) in left.validGroupActions(combatants)" :key="'left-' + action.name + '-' + index" :action="action" :user="left" :target="right" :combatants="combatants" /> <ActionButton @described="described" @executed="executedLeft" v-for="(action, index) in left.validGroupActions(combatants)" :key="'left-' + action.name + '-' + index" :action="action" :user="left" :target="right" :combatants="combatants" />
<i class="action-label fas fa-user-friends" v-if="left.validActions(right).length > 0"></i>
<ActionButton @described="described" @executed="executedLeft" v-for="(action, index) in left.validActions(right)" :key="'left-' + action.name + '-' + index" :action="action" :user="left" :target="right" :combatants="combatants" />
<i class="action-label fas fa-user-friends" v-if="left.validActions(right).length > 0 && left !== right"></i>
<ActionButton @described="described" @executed="executedLeft" v-for="(action, index) in left === right ? [] : left.validActions(right)" :key="'left-' + action.name + '-' + index" :action="action" :user="left" :target="right" :combatants="combatants" />
<i class="action-label fas fa-user" v-if="left.validActions(left).length > 0"></i> <i class="action-label fas fa-user" v-if="left.validActions(left).length > 0"></i>
<ActionButton @described="described" @executed="executedLeft" v-for="(action, index) in left.validActions(left)" :key="'left-' + action.name + '-' + index" :action="action" :user="left" :target="left" :combatants="combatants" /> <ActionButton @described="described" @executed="executedLeft" v-for="(action, index) in left.validActions(left)" :key="'left-' + action.name + '-' + index" :action="action" :user="left" :target="left" :combatants="combatants" />
</div> </div>
@@ -34,8 +34,8 @@
<div v-if="encounter.currentMove === right" class="vert-display"> <div v-if="encounter.currentMove === right" class="vert-display">
<i class="action-label fas fa-users" v-if="right.validGroupActions(combatants).length > 0"></i> <i class="action-label fas fa-users" v-if="right.validGroupActions(combatants).length > 0"></i>
<ActionButton @described="described" @executed="executedRight" v-for="(action, index) in right.validGroupActions(combatants)" :key="'right-' + action.name + '-' + index" :action="action" :user="right" :target="left" :combatants="combatants" /> <ActionButton @described="described" @executed="executedRight" v-for="(action, index) in right.validGroupActions(combatants)" :key="'right-' + action.name + '-' + index" :action="action" :user="right" :target="left" :combatants="combatants" />
<i class="action-label fas fa-user-friends" v-if="right.validActions(left).length > 0"></i>
<ActionButton @described="described" @executed="executedRight" v-for="(action, index) in right.validActions(left)" :key="'right-' + action.name + '-' + index" :action="action" :user="right" :target="left" :combatants="combatants" />
<i class="action-label fas fa-user-friends" v-if="right.validActions(left).length > 0 && right !== left"></i>
<ActionButton @described="described" @executed="executedRight" v-for="(action, index) in right === left ? [] : right.validActions(left)" :key="'right-' + action.name + '-' + index" :action="action" :user="right" :target="left" :combatants="combatants" />
<i class="action-label fas fa-user" v-if="right.validActions(right).length > 0"></i> <i class="action-label fas fa-user" v-if="right.validActions(right).length > 0"></i>
<ActionButton @described="described" @executed="executedRight" v-for="(action, index) in right.validActions(right)" :key="'right-' + action.name + '-' + index" :action="action" :user="right" :target="right" :combatants="combatants" /> <ActionButton @described="described" @executed="executedRight" v-for="(action, index) in right.validActions(right)" :key="'right-' + action.name + '-' + index" :action="action" :user="right" :target="right" :combatants="combatants" />
</div> </div>


+ 17
- 1
src/game/maps/town.ts Просмотреть файл

@@ -286,7 +286,7 @@ export const Town = (): Place => {
name: "Fight some tasty nerd", name: "Fight some tasty nerd",
intro: () => new LogLine(`You find some nerd to fight.`) intro: () => new LogLine(`You find some nerd to fight.`)
}, },
[world.player, enemy]
[world.player, enemy].concat(world.party)
) )
world.encounter = encounter world.encounter = encounter
return nilLog return nilLog
@@ -294,6 +294,22 @@ export const Town = (): Place => {
) )
) )


westAve.choices.push(
new Choice(
"Recruit someone",
"Not ow",
(world) => {
const ally = new Creatures.Human(new ProperNoun("Ally"), TheyPronouns)
ally.side = Side.Heroes
ally.ai = new VoreAI()
ally.equip(new Items.Sword(), Items.EquipmentSlot.MainHand)
world.party.push(ally)

return new LogLine(`You recruit a nerd`)
}
)
)

square.choices.push( square.choices.push(
new Choice( new Choice(
"Fight Geta", "Fight Geta",


+ 1
- 0
src/game/world.ts Просмотреть файл

@@ -92,6 +92,7 @@ export class World {
time: Moment time: Moment
creatures: Creature[] = [] creatures: Creature[] = []
encounter: Encounter|null = null encounter: Encounter|null = null
party: Creature[] = []


constructor (public player: Creature) { constructor (public player: Creature) {
this.time = moment.utc([500, 1, 1, 9, 0, 0, 0]) this.time = moment.utc([500, 1, 1, 9, 0, 0, 0])


Загрузка…
Отмена
Сохранить