-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommandList.ts
More file actions
48 lines (39 loc) · 1020 Bytes
/
commandList.ts
File metadata and controls
48 lines (39 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { ICommand, Attack, Item } from './types';
import { BattleService } from './services/BattleService';
import { ItemService } from './services/ItemService';
/*
* ---- UseItemCommand ----
* Allows the user to use an item during a pokemon battle
*/
export class UseItemCommand extends ICommand {
public constructor(private itemService: ItemService) {
super()
}
execute(item: Item) {
this.itemService.useItem(item)
}
}
/*
* ---- AttackCommand ----
* Allows the user to select an attack to use in a pokemon battle
*/
export class AttackCommand extends ICommand {
public constructor(private battleService: BattleService) {
super()
}
execute(attack: Attack) {
this.battleService.attack(attack)
}
}
/*
* ---- RunAwayCommand ----
* Allows the user to attempt to run away from the battle (50/50 chance)
*/
export class RunAwayCommand extends ICommand {
public constructor(private battleService: BattleService) {
super()
}
execute(randInt: number) {
this.battleService.runAway(randInt)
}
}