Skip to content

Commit c440d56

Browse files
[Story mode] Add optional challenges (#208)
* Add support for optional challenges. * Add optional challenges
1 parent d0c334d commit c440d56

5 files changed

Lines changed: 117 additions & 20 deletions

File tree

4.9 KB
Loading

rlbot_gui/gui/js/story-challenges.js

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import StoryUpgrades from './story-upgrades.js';
32
import StoryPickTeam from './story-pick-team.js';
43
import StoryRecruitList from './story-recruit-list.js';
@@ -8,12 +7,14 @@ const DEBUG = false;
87
const CITY_STATE = {
98
'LOCKED': 0,
109
'OPEN': 1,
11-
'DONE': 2
10+
'OPTIONALS_LEFT': 2,
11+
'DONE': 3
1212
};
1313

1414
const CITY_ICON_MAP = [
1515
'imgs/story/lock-100px.png', // LOCKED
16-
'',
16+
'', // OPEN
17+
'imgs/story/checkmark-outline-100px.png', // OPTIONALS_LEFT
1718
'imgs/story/checkmark-100px.png' // DONE
1819
];
1920

@@ -193,7 +194,7 @@ export default {
193194
<b-button block
194195
@click="$refs.pickTeamPopup.show(challenge)"
195196
v-bind:variant="challengeCompleted(challenge.id)? 'outline-dark' : 'outline-primary' ">
196-
{{challenge.display}}
197+
{{!!challenge.optional ? "Optional: " + challenge.display : challenge.display}}
197198
</b-button>
198199
</b-list-group-item>
199200
</b-list-group>
@@ -273,7 +274,6 @@ export default {
273274
return result;
274275
},
275276
recruit_list: function () {
276-
const completed = this.saveState.challenges_completed;
277277
let recruits = {};
278278

279279
for (let city of Object.keys(this.challenges)) {
@@ -306,13 +306,17 @@ export default {
306306
return;
307307
}
308308
else {
309-
let open_cities = Object.keys(
310-
this.cityDisplayInfo).filter((city) =>
311-
this.getCityState(city) == CITY_STATE.OPEN);
312-
313-
let random = open_cities[Math.floor(Math.random() * open_cities.length)];
314-
console.log(random);
315-
this.selectedCityId = random;
309+
let open_cities = Object.keys(this.cityDisplayInfo)
310+
.filter((city) => this.getCityState(city) == CITY_STATE.OPEN);
311+
// Fall back to cities with optional challenges left
312+
if (open_cities.length === 0)
313+
open_cities = Object.keys(this.cityDisplayInfo)
314+
.filter((city) => this.getCityState(city) == CITY_STATE.OPTIONALS_LEFT);
315+
// Fall back to cur
316+
if (open_cities.length === 0)
317+
this.selectedCityId = cur;
318+
else
319+
this.selectedCityId = open_cities[Math.floor(Math.random() * open_cities.length)];
316320
}
317321
},
318322
challengeCompleted: function (id) {
@@ -325,6 +329,7 @@ export default {
325329
const suffix = [
326330
'is still locked.',
327331
'is open to challenge!',
332+
'has optional challenges!',
328333
'has been completed!'
329334
];
330335
return displayName + ' ' + suffix[state];
@@ -341,13 +346,23 @@ export default {
341346
let state = CITY_STATE.LOCKED;
342347

343348
let prereqs = this.cityDisplayInfo[city].prereqs;
344-
if (prereqs.every(c => (this.getCityState(c) === CITY_STATE.DONE))) {
345-
state = CITY_STATE.OPEN;
349+
if (prereqs.every(c => [CITY_STATE.DONE, CITY_STATE.OPTIONALS_LEFT].includes(this.getCityState(c)))) {
350+
let anyOptionalsLeft = false
351+
let anyRequiredLeft = false
346352

347-
// only need to check completion of challenges if we are open
348353
let cityChallenges = this.challenges[city];
349-
if (cityChallenges.every(c => this.challengeCompleted(c.id))) {
350-
state = CITY_STATE.DONE;
354+
for (const c of cityChallenges) {
355+
if (!this.challengeCompleted(c.id)) {
356+
if (!!c.optional) anyOptionalsLeft = true
357+
else anyRequiredLeft = true
358+
}
359+
}
360+
if (anyRequiredLeft) {
361+
state = CITY_STATE.OPEN
362+
} else if (anyOptionalsLeft) {
363+
state = CITY_STATE.OPTIONALS_LEFT
364+
} else {
365+
state = CITY_STATE.DONE
351366
}
352367
}
353368
return state;

rlbot_gui/story/bots-base.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@
9494
"type": "rlbot",
9595
"path": ["$RLBOTPACKROOT", "RLBotPack", "PhoenixCS", "phoenix.cfg"]
9696
},
97+
"broccoli": {
98+
"name": "BroccoliBot",
99+
"type": "rlbot",
100+
"path": ["$RLBOTPACKROOT", "RLBotPack", "BroccoliBot", "BroccoliBot.cfg"]
101+
},
102+
"bribble": {
103+
"name": "Bribblebot",
104+
"type": "rlbot",
105+
"path": ["$RLBOTPACKROOT", "RLBotPack", "Bribblebot", "bot.cfg"]
106+
},
97107
"atlas": {
98108
"name": "Atlas",
99109
"type": "rlbot",
@@ -119,6 +129,16 @@
119129
"type": "rlbot",
120130
"path": ["$RLBOTPACKROOT", "RLBotPack", "beastbot", "beastbot.cfg"]
121131
},
132+
"noobbot": {
133+
"name": "Noob Bot",
134+
"type": "rlbot",
135+
"path": ["$RLBOTPACKROOT", "RLBotPack", "Noob_Bot", "src", "bot.cfg"]
136+
},
137+
"monkey": {
138+
"name": "Monkey",
139+
"type": "rlbot",
140+
"path": ["$RLBOTPACKROOT", "RLBotPack", "Monkey", "bot.cfg"]
141+
},
122142
"cryo": {
123143
"name": "Codename Cryo",
124144
"type": "rlbot",

rlbot_gui/story/story-default.json

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
"map": "BeckwithPark",
1616
"disabledBoost": true,
1717
"display": "Win something so we know you can drive"
18+
},
19+
{
20+
"id": "INTRO-2",
21+
"humanTeamSize": 1,
22+
"opponentBots": ["noobbot"],
23+
"optional": true,
24+
"map": "BeckwithPark_Dawn",
25+
"display": "A training partner challenges you"
1826
}
1927
]
2028
},
@@ -42,6 +50,14 @@
4250
},
4351
"map": "UrbanCentral_Dawn",
4452
"display": "Upgrade your reputation by beating your opponents by 3 or more goals"
53+
},
54+
{
55+
"id": "TRYHARD-3",
56+
"humanTeamSize": 1,
57+
"opponentBots": ["monkey"],
58+
"optional": true,
59+
"map": "UrbanCentral_Dawn",
60+
"display": "A stranger is experimenting with their new ML tech."
4561
}
4662
]
4763
},
@@ -65,6 +81,18 @@
6581
"opponentBots": ["rashbot", "stick", "leaf"],
6682
"map": "Mannfield_Stormy",
6783
"display": "2v3! Get through this storm of Marvin bots!"
84+
},
85+
{
86+
"id": "PBOOST-3",
87+
"humanTeamSize": 2,
88+
"opponentBots": ["broccoli", "molten", "phoenix"],
89+
"completionConditions": {
90+
"win": true,
91+
"scoreDifference": 3
92+
},
93+
"optional": true,
94+
"map": "DFHStadium_Stormy",
95+
"display": "Broccoli and bots on fire - this place is wild"
6896
}
6997
]
7098
},
@@ -96,6 +124,14 @@
96124
},
97125
"map": "Wasteland",
98126
"display": "Win and get at least two demos"
127+
},
128+
{
129+
"id": "WASTELAND-3",
130+
"humanTeamSize": 3,
131+
"opponentBots": ["bribble", "bribble", "wildfire"],
132+
"map": "Wasteland_Night",
133+
"optional": true,
134+
"display": "These bot wants to show you what strategic demos are"
99135
}
100136
]
101137
},
@@ -134,19 +170,27 @@
134170
"display": "There's something unnatural about these bots..."
135171
},
136172
{
137-
"id": "CS-5",
173+
"id": "CS-4",
138174
"humanTeamSize": 1,
139175
"opponentBots": ["snek", "peter"],
140176
"max_score": "3 Goals",
141177
"map": "NeoTokyo",
142178
"display": "How does that car turn so fast?"
143179
},
144180
{
145-
"id": "CS-4",
181+
"id": "CS-5",
146182
"humanTeamSize": 2,
147183
"opponentBots": ["invisibot"],
148184
"map": "NeoTokyo",
149185
"display": "Wait where did that car go?"
186+
},
187+
{
188+
"id": "CS-6",
189+
"humanTeamSize": 1,
190+
"opponentBots": ["snek", "snek", "snek"],
191+
"map": "NeoTokyo",
192+
"optional": true,
193+
"display": "You find yourself in a game of Tron"
150194
}
151195
]
152196
},
@@ -198,6 +242,22 @@
198242
"opponentBots": ["nexto"],
199243
"map": "ChampionsField_Day",
200244
"display": "You made it to the top. Time to face the champion."
245+
},
246+
{
247+
"id": "CHAMP-7",
248+
"humanTeamSize": 1,
249+
"opponentBots": ["invisibot", "invisibot"],
250+
"map": "Mannfield_Night",
251+
"optional": true,
252+
"display": "A master does not have to see their opponents. Right?"
253+
},
254+
{
255+
"id": "CHAMP-8",
256+
"humanTeamSize": 1,
257+
"opponentBots": ["nexto", "nexto"],
258+
"map": "ChampionsField_Day",
259+
"optional": true,
260+
"display": "The ultimate champion challenge"
201261
}
202262
]
203263
}

rlbot_gui/story/story-easy.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@
2727
"challenges": [
2828
{
2929
"id": "TRYHARD-1",
30+
"optional": true,
3031
"humanTeamSize": 2,
3132
"opponentBots": ["nombot", "beast"],
3233
"map": "UrbanCentral",
3334
"display": "Beat local up-and-comers in a 2v2."
3435
},
3536
{
3637
"id": "TRYHARD-2",
38+
"optional": true,
3739
"humanTeamSize": 2,
3840
"opponentBots": ["penguin", "beast"],
3941
"completionConditions": {
@@ -175,7 +177,7 @@
175177
"display": "This ML prodigy would like to have a word with you."
176178
},
177179
{
178-
"id": "CHAMP-4",
180+
"id": "CHAMP-5",
179181
"humanTeamSize": 3,
180182
"opponentBots": ["bumblebee", "bumblebee", "bumblebee"],
181183
"map": "ChampionsField",

0 commit comments

Comments
 (0)