-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip items sets * add modifiers * enable all magics
- Loading branch information
Showing
34 changed files
with
491 additions
and
244 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
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,17 @@ | ||
import arena from '@/arena'; | ||
|
||
export type Action = keyof typeof arena.actions; | ||
|
||
export class ActionService { | ||
static isAction(maybeAction: string): maybeAction is Action { | ||
return maybeAction in arena.actions; | ||
} | ||
|
||
static isBaseAction(action: string) { | ||
if (ActionService.isAction(action)) { | ||
return arena.actions[action].lvl === 0; | ||
} | ||
|
||
return false; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import arena from '@/arena'; | ||
import { type Action, ActionService } from '@/arena/ActionService'; | ||
import type Game from '@/arena/GameService'; | ||
import config from '@/arena/config'; | ||
import _ from 'lodash'; | ||
|
||
type Stages = Readonly<(Action | Readonly<Action[]>)[]>; | ||
|
||
/** | ||
* @param stages массив строк | ||
* @param game объект игры | ||
* @return измененный объект игры | ||
*/ | ||
function runStage(stages: Stages, game: Game) { | ||
const ordersByAction = Object.groupBy(game.orders.ordersList, ({ action }) => action); | ||
stages.forEach((stage) => { | ||
if (typeof stage !== 'string') { | ||
runStage(stage, game); | ||
return; | ||
} | ||
|
||
console.log('stage run:', stage); | ||
if (!ActionService.isAction(stage)) { | ||
console.log('stage fail (unknown action):', stage); | ||
return; | ||
} | ||
const action = arena.actions[stage]; | ||
const orders = ordersByAction[stage]; | ||
if (!orders) { | ||
return; | ||
} | ||
|
||
orders.forEach((order) => { | ||
const initiator = game.players.getById(order.initiator); | ||
const target = game.players.getById(order.target); | ||
if (initiator && target) { | ||
// FIXME прокидывать проценты в action вместо initiator | ||
initiator.setProc(order.proc / 100); | ||
action.cast(initiator, target, game); | ||
} else { | ||
console.log('stage fail (no player):', initiator?.id, target?.id); | ||
} | ||
}); | ||
|
||
if ('castLong' in action) { | ||
action.castLong(game); | ||
} | ||
}); | ||
return game; | ||
} | ||
|
||
/** | ||
* Engine | ||
* Модуль обработки боя | ||
* @todo wip | ||
*/ | ||
|
||
/** | ||
* @param game Объект игры | ||
*/ | ||
export function engine(game: Game): Game | undefined { | ||
try { | ||
return runStage(config.stages, game); | ||
} catch (e) { | ||
console.debug(e); | ||
} finally { | ||
console.info('engine done'); | ||
} | ||
} |
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
Oops, something went wrong.