-
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.
* Rewrite PhysConstructor to TS * Affects v2
- Loading branch information
Showing
67 changed files
with
1,106 additions
and
1,490 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
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,47 @@ | ||
import { BaseAction } from './BaseAction'; | ||
import type { PostAffect } from './interfaces/PostAffect'; | ||
import type { PreAffect } from './interfaces/PreAffect'; | ||
import type { SuccessArgs } from './types'; | ||
|
||
export abstract class AffectableAction extends BaseAction { | ||
private preAffects: PreAffect[] = []; | ||
private postAffects: PostAffect[] = []; | ||
private affects: SuccessArgs[] = []; | ||
|
||
registerPreAffects(preAffects: PreAffect[]) { | ||
this.preAffects = preAffects; | ||
} | ||
|
||
registerPostAffects(postAffects: PostAffect[]) { | ||
this.postAffects = postAffects; | ||
} | ||
|
||
checkPreAffects(params = this.params, status = this.status) { | ||
this.preAffects.forEach((preAffect) => { | ||
preAffect.preAffect(params, status); | ||
}); | ||
} | ||
|
||
checkPostAffects(params = this.params, status = this.status) { | ||
this.postAffects.forEach((preAffect) => { | ||
const result = preAffect.postAffect(params, status); | ||
if (!result) { | ||
return; | ||
} | ||
|
||
const normalizedResult = Array.isArray(result) ? result : [result]; | ||
|
||
this.affects.push(...normalizedResult); | ||
}); | ||
} | ||
|
||
getAffects() { | ||
return this.affects; | ||
} | ||
|
||
reset() { | ||
super.reset(); | ||
|
||
this.affects = []; | ||
} | ||
} |
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,25 @@ | ||
import type GameService from '@/arena/GameService'; | ||
import type { Player } from '@/arena/PlayersService'; | ||
|
||
export abstract class BaseAction { | ||
params: { | ||
initiator: Player; | ||
target: Player; | ||
game: GameService | ||
}; | ||
|
||
status = { effect: 0, exp: 0 }; | ||
|
||
abstract cast(initiator: Player, target: Player, game: GameService) | ||
|
||
/** | ||
* @param initiator объект персонажа | ||
* @param target объект персонажа | ||
* @param game Объект игры для доступа ко всему | ||
*/ | ||
abstract run(initiator: Player, target: Player, game: GameService) | ||
|
||
reset() { | ||
this.status = { effect: 0, exp: 0 }; | ||
} | ||
} |
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.