-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.closure.template.js
95 lines (87 loc) · 2.74 KB
/
bot.closure.template.js
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
function createExamplePlayer() {
/**
* OPTIONAL method / lifecycle hook.
* Called by the framework to notify Player the start of the Match, providing the rules for the Match
*
* Parameters:
* matchRules - { rounds: <numberOfRoundsInMatch> }
*/
function onMatchStart(matchRules) {}
/**
* OPTIONAL method / lifecycle hook.
* Called by the framework to notify Player the start of the Match, providing the rules for the Match
*
* Parameters:
* matchRules - { rounds: <numberOfRoundsInMatch> }
*/
function onMatchStart(matchRules) {}
/**
* OPTIONAL method / lifecycle hook.
* Called by the framework to notify Player of the start of a Round, providing the rules for the Round
*
* Parameters:
* roundRules - {
* turns: <maxNumberOfTurnsInRound>,
* defenderBonus: <amountOfBonusAttackPowerWhenDefending>
* }
*/
function onRoundStart(roundRules) {}
/**
* REQUIRED method!
* Called by the framework to solicit the Player's actions each turn, providing the Player's current state.
* This is the only mechanism by which the Player is able to communicate with the Game.
*
* Parameters:
* playerState - {
* producers: <currentProducerCount>,
* soldiers: <currentSoldierCount>
* }
*
* Expected Return Value: PlayerActions
* {
* newProducers: <numberOfNewProducersToProduce>,
* newSoldiers: <numberOfNewSoldiersToProduce>,
* launchAttack: <true | false -- set to true to launch attack with your soldiers at end of turn>
* }
*/
function playTurn(playerState) {
return {
newProducers: 0,
newSoldiers: 0,
launchAttack: false
};
}
/**
* OPTIONAL method.
* Called by the framework to notify Player of the end of a Round, providing the results of the round.
*
* Parameters:
* roundResult - {
* outcome: <'WIN' | 'LOSS' | 'DRAW'>,
* turnsPlayed: <numberOfTurnsPlayedInRound>,
* you: {
* producers: <yourProducerCountAtEndOfRound>,
* soldiers: <yourSoldierCountAtEndOfRound>,
* attackLaunched: <true | false -- true if you launched attack on last turn>
* },
* them: {
* producers: <theirProducerCountAtEndOfRound>,
* soldiers: <theirSoldierCountAtEndOfRound>,
* attackLaunched: <true | false -- true if they launched attack on last turn>
* }
* }
*/
function onRoundEnd(roundResult) { }
// Finally, return your Player object here. Don't forget to set metadata :-)
return {
meta: {
name: 'Name of Your Bot',
author: 'Your Name'
},
onMatchStart, // Optional
onRoundStart, // Optional
playTurn,
onRoundEnd // Optional
};
}
export default createExamplePlayer;