Skip to content

Commit

Permalink
Show players needed for transition
Browse files Browse the repository at this point in the history
  • Loading branch information
silviot committed Aug 15, 2023
1 parent 0e05a3a commit 3afe48d
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 7 deletions.
13 changes: 13 additions & 0 deletions dlgr/griduniverse/game_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,16 @@ transitions:
- -1
target_end: empty_gooseberry_bush
target_start: gooseberry_bush

# The following is a dummy test trasition to
# assist developement of multi-actor transitions
- actor_start: null
actor_end: null
required_actors: 2
target_start: stone
target_end: sharp_stone
visible: always
last_use: false
modify_uses:
- 0
- 0
34 changes: 32 additions & 2 deletions dlgr/griduniverse/static/scripts/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,30 @@ var playerSet = (function () {
return distances[0].player;
};

PlayerSet.prototype.getAdjacentPlayers = function () {
/* Return a list of players adjacent to the ego player */
adjacentPlayers = [];
let egoPostiion = this._players[ego].position;
for (id in this._players) {
if (id === ego) {
continue;
}
if (this._players.hasOwnProperty(id)) {
let player = this._players[id];
if (player.hasOwnProperty('position')) {
let position = player.position;
if (position[0] === egoPostiion[0] && Math.abs(position[1] - egoPostiion[1]) === 1) {
adjacentPlayers.push(player);
}
if (position[1] === egoPostiion[1] && Math.abs(position[0] - egoPostiion[0]) === 1) {
adjacentPlayers.push(player);
}
}
}
}
return adjacentPlayers;
};

PlayerSet.prototype.ego = function () {
return this.get(this.ego_id);
};
Expand Down Expand Up @@ -1024,8 +1048,14 @@ function renderTransition(transition) {
aEndItemString = `✋${aEndItem ? aEndItem.name: '⬜'}`;
tEndItemString = tEndItem ? tEndItem.name: '⬜';
}
return `${aStartItemString} + ${tStartItemString}${aEndItemString} + ${tEndItemString}`;

var actors_info = "";
const required_actors = transition.transition.required_actors
// The total number of actors is the number of adjacent players plus one for ego (the current player)
const neighbouringActors = players.getAdjacentPlayers().length + 1;
if (neighbouringActors < required_actors) {
actors_info = ` - not available: ${required_actors - neighbouringActors} more players needed`;
}
return `${aStartItemString} + ${tStartItemString}${aEndItemString} + ${tEndItemString}${actors_info}`;
}
/**
* If the current player is sharing a grid position with an interactive
Expand Down
34 changes: 32 additions & 2 deletions dlgr/griduniverse/static/scripts/dist/bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dlgr/griduniverse/static/scripts/dist/bundle.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dlgr/griduniverse/static/scripts/dist/difi.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dlgr/griduniverse/static/scripts/dist/questionnaire.js.map

Large diffs are not rendered by default.

0 comments on commit 3afe48d

Please sign in to comment.