Skip to content

Commit

Permalink
V1.0.46 (#49)
Browse files Browse the repository at this point in the history
* Logo support

* Final version of the new community events

* Bring Story mode settings up to date

* Update items.csv

* New items/maps

Update items.csv

* New formatting
  • Loading branch information
VirxEC authored Jun 20, 2023
1 parent 8b1f98f commit 4c21acd
Show file tree
Hide file tree
Showing 22 changed files with 1,523 additions and 612 deletions.
194 changes: 192 additions & 2 deletions assets/csv/items.csv

Large diffs are not rendered by default.

Binary file added assets/imgs/story/checkmark-outline-100px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
129 changes: 80 additions & 49 deletions assets/js/community-events-vue.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
export default {
name: "community-events",
template: /*html*/ `
<b-modal title="Community Events" id="community-events" size="lg" centered ok-only>
<div v-if="events.length == 0">
<p>There are no community events at this time.</p>
</div>
<div v-else v-for="event in events">
<h3>{{ event.name }}</h3>
<p v-if="event.timeUntilMs > 0" class="mb-1">
<b-modal title="Community Events" id="community-events" size="xl" centered ok-only>
<div v-if="events.length == 0">
<p>There are no community events at this time.</p>
</div>
<div v-else v-for="event in events">
<div class="d-flex align-items-center">
<img v-if="event.logo" :src="event.logo" class="mr-3" style="max-width: 100%; max-height: 150px;"/>
<div>
<h3>{{ event.name }}</h3>
<p v-if="event.timeUntilMs > 0" class="mb-1">
<b-icon icon="calendar-plus"/> Starts in <b>{{ event.timeUntil }}</b> ({{ event.time }})
</p>
<p v-else class="mb-1">
</p>
<p v-else class="mb-1">
<b-icon icon="alarm"/> Started <b>{{ event.timeUntil }}</b> ago, but you can still join!
</p>
<p>
<b-icon icon="geo"/> <a :href="event.location" target="_blank">{{ event.location }}</a>
</p>
</div>
</b-modal>
</p>
<p>
<b-icon icon="geo"/> <a :href="event.location" target="_blank">{{ event.location }}</a>
</p>
<p v-if="event.moreInfo">
<b-icon icon="info-circle"/> <a :href="event.moreInfo" target="_blank">More info</a>
</p>
</div>
</div>
</div>
</b-modal>
`,
data() {
return {
Expand All @@ -32,39 +40,45 @@ export default {
const start = event.start.dateTime;
let new_date = new Date(start);

try {
const recurrence = event.recurrence[0].split(";");
const rec_type = recurrence[0].split("=")[1];
const interval = recurrence[2].split("=")[1];
const end_date_type = recurrence[2].split("=")[0];
const end_date_raw = recurrence[2].split("=")[1];
let end_date = new Date(new_date);
if (end_date_type == "COUNT") {
if (rec_type == "WEEKLY") {
end_date.setDate(new_date.getDate() + 7 * interval * end_date_raw);
} else if (rec_type == "MONTHLY") {
end_date.setDate(new_date.getDate() + 4 * interval * end_date_raw);
}
} else {
end_date.setDate(end_date_raw);
}
if (rec_type == "WEEKLY") {
while (new_date <= end_date) {
if (new_date > today) {
break;
if (event.recurrence) {
try {
const recurrence = event.recurrence[0].split(";");
const rec_type = recurrence[0].split("=")[1];
const interval = recurrence[2].split("=")[1];
const end_date_type = recurrence[2].split("=")[0];
const end_date_raw = recurrence[2].split("=")[1];
let end_date = new Date(new_date);
if (end_date_type == "COUNT") {
if (rec_type == "WEEKLY") {
end_date.setDate(
new_date.getDate() + 7 * interval * end_date_raw
);
} else if (rec_type == "MONTHLY") {
end_date.setDate(
new_date.getDate() + 4 * interval * end_date_raw
);
}
new_date.setDate(new_date.getDate() + 7);
} else {
end_date.setDate(end_date_raw);
}
} else if (rec_type == "MONTHLY") {
while (new_date <= end_date) {
if (new_date > today) {
break;
if (rec_type == "WEEKLY") {
while (new_date <= end_date) {
if (new_date > today) {
break;
}
new_date.setDate(new_date.getDate() + 7);
}
} else if (rec_type == "MONTHLY") {
while (new_date <= end_date) {
if (new_date > today) {
break;
}
new_date.setDate(new_date.getDate() + 4);
}
new_date.setDate(new_date.getDate() + 4);
}
} catch (e) {
console.error("Error checking recurrence:" + e);
}
} catch (e) {
console.error("Error checking recurrence:" + e);
}

const time_untils = new_date.getTime() - today.getTime();
Expand Down Expand Up @@ -119,21 +133,38 @@ export default {
event
);

if (time_until_ms > 0)
this.eventsFuture += 1;
else
this.eventsNow += 1;
if (time_until_ms > 0) this.eventsFuture += 1;
else this.eventsNow += 1;

// time_untils is the time until the event in milliseconds
// convert this to something human readable, like "in 2 days"
const format = this.formatFromNow(Math.abs(time_until_ms));

let logo =
event.description && event.description.includes("logo:")
? event.description
.split("logo:")[1]
.replace("\n", "")
.split('href="')[1]
.split('"')[0]
: null;

let description = event.description
? event.description
.split("logo:")[0]
.replace("\n", "")
.split('href="')[1]
.split('"')[0]
: null;

this.events.push({
name: names,
location: event.location,
time: new_date.toLocaleString(),
timeUntil: format,
timeUntilMs: time_until_ms,
moreInfo: description,
logo: logo,
});
}

Expand All @@ -142,8 +173,8 @@ export default {
return new Date(a.timeUntilMs) - new Date(b.timeUntilMs);
});

// only show the first 3
this.events = this.events.slice(0, 3);
// only show the first 4
this.events = this.events.slice(0, 4);
});
});
},
Expand Down
67 changes: 48 additions & 19 deletions assets/js/story-challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ const DEBUG = false;
const CITY_STATE = {
LOCKED: 0,
OPEN: 1,
DONE: 2,
OPTIONALS_LEFT: 2,
DONE: 3,
};

const CITY_ICON_MAP = [
"imgs/story/lock-100px.png", // LOCKED
"",
"", // OPEN
"imgs/story/checkmark-outline-100px.png", // OPTIONALS_LEFT
"imgs/story/checkmark-100px.png", // DONE
];

Expand Down Expand Up @@ -198,7 +200,7 @@ export default {
<b-button block
@click="$refs.pickTeamPopup.show(challenge)"
v-bind:variant="challengeCompleted(challenge.id)? 'outline-dark' : 'outline-primary' ">
{{challenge.display}}
{{!!challenge.optional ? "Optional: " + challenge.display : challenge.display}}
</b-button>
</b-list-group-item>
</b-list-group>
Expand Down Expand Up @@ -283,14 +285,20 @@ export default {
return result;
},
recruit_list: function () {
const recruits = {};
let recruits = {};

for (const city of Object.keys(this.challenges)) {
if (this.getCityState(city) !== CITY_STATE.DONE) {
// You can recruit bots from mandatory challenges of
// a city once all the mandatory challenges of that city is complete.
for (let city of Object.keys(this.challenges)) {
const state = this.getCityState(city);
if (state === CITY_STATE.LOCKED || state === CITY_STATE.OPEN) {
continue;
}
for (const challenge of this.challenges[city]) {
// This challenge was completed so opponents are available
for (let challenge of this.challenges[city]) {
if (challenge.optional) {
continue;
}
// This challenge was mandatory and now completed so opponents are available
const botIds = challenge.opponentBots;
for (const botId of botIds) {
const bot = Object.assign({}, this.bots_config[botId]);
Expand All @@ -317,13 +325,18 @@ export default {
// current city is stll open, that's fine
} else {
const openCities = Object.keys(this.cityDisplayInfo).filter(
(city) => this.getCityState(city) === CITY_STATE.OPEN
(city) => this.getCityState(city) == CITY_STATE.OPEN
);

const random =
openCities[Math.floor(Math.random() * openCities.length)];
console.log(random);
this.selectedCityId = random;
// Fall back to cities with optional challenges left
if (openCities.length === 0)
openCities = Object.keys(this.cityDisplayInfo).filter(
(city) => this.getCityState(city) == CITY_STATE.OPTIONALS_LEFT
);
// Fall back to cur
if (openCities.length === 0) this.selectedCityId = cur;
else
this.selectedCityId =
openCities[Math.floor(Math.random() * openCities.length)];
}
},
challengeCompleted: function (id) {
Expand Down Expand Up @@ -352,12 +365,28 @@ export default {
let state = CITY_STATE.LOCKED;

const prereqs = this.cityDisplayInfo[city].prereqs;
if (prereqs.every((c) => this.getCityState(c) === CITY_STATE.DONE)) {
state = CITY_STATE.OPEN;
if (
prereqs.every((c) =>
[CITY_STATE.DONE, CITY_STATE.OPTIONALS_LEFT].includes(
this.getCityState(c)
)
)
) {
let anyOptionalsLeft = false;
let anyRequiredLeft = false;

// only need to check completion of challenges if we are open
const cityChallenges = this.challenges[city];
if (cityChallenges.every((c) => this.challengeCompleted(c.id))) {
let cityChallenges = this.challenges[city];
for (const c of cityChallenges) {
if (!this.challengeCompleted(c.id)) {
if (!!c.optional) anyOptionalsLeft = true;
else anyRequiredLeft = true;
}
}
if (anyRequiredLeft) {
state = CITY_STATE.OPEN;
} else if (anyOptionalsLeft) {
state = CITY_STATE.OPTIONALS_LEFT;
} else {
state = CITY_STATE.DONE;
}
}
Expand Down
Loading

0 comments on commit 4c21acd

Please sign in to comment.