Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement client side transition visibility #258

Merged
merged 5 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions dlgr/griduniverse/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
mode = debug
auto_recruit = true
network = FullyConnected
max_participants = 3
time_per_round = 30
max_participants = 1
num_rounds = 3
time_per_round = 45
block_size = 20
columns = 200
rows = 100
window_rows = 20
window_columns = 20
use_identicons = true

[HIT Configuration]
title = Griduniverse
Expand Down
18 changes: 10 additions & 8 deletions dlgr/griduniverse/game_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ item_defaults:
sprite: "#8a9b0f,#7a6b54"

transition_defaults:
visible: never # Can be set to "never", "always", or "seen" for transitions that become
visible: seen # Can be set to "never", "always", or "seen" for transitions that become
# visible to a player after they have been executed for the first time
actor_end: null
actor_start: null
Expand Down Expand Up @@ -83,7 +83,7 @@ items:
item_id: wild_carrot_plant
portable: true
spawn_rate: 0.15
item_count: 2
item_count: 100
sprite: "#E67E22"

- crossable: true
Expand All @@ -92,7 +92,7 @@ items:
item_id: stone
portable: true
spawn_rate: 0.05
item_count: 5
item_count: 50
sprite: "#95A5A6"

- crossable: true
Expand All @@ -101,7 +101,7 @@ items:
item_id: big_hard_rock
portable: false
spawn_rate: 0
item_count: 2
item_count: 20
sprite: "#7F8C8D"

- crossable: true
Expand All @@ -111,7 +111,7 @@ items:
item_id: gooseberry_bush
portable: false
spawn_rate: 0.1
item_count: 2
item_count: 50
sprite: "#8E44AD"

- crossable: true
Expand All @@ -120,7 +120,7 @@ items:
item_id: sharp_stone
portable: true
spawn_rate: 0.05
item_count: 5
item_count: 20
sprite: "#BDC3C7"

- calories: 5
Expand All @@ -130,7 +130,7 @@ items:
name: Wild Carrot
item_id: wild_carrot
portable: true
spawn_rate: 0.1
spawn_rate: 0
item_count: 0
sprite: "#E67E22"

Expand All @@ -141,7 +141,7 @@ items:
name: Gooseberry
item_id: gooseberry
portable: true
spawn_rate: 0.1
spawn_rate: 0
item_count: 0
sprite: "#8E44AD"

Expand Down Expand Up @@ -179,6 +179,7 @@ transitions:
- actor_end: gooseberry
actor_start: null
last_use: false
visible: never
modify_uses:
- 0
- -1
Expand All @@ -188,6 +189,7 @@ transitions:
- actor_end: gooseberry
actor_start: null
last_use: true
visible: always
modify_uses:
- 0
- -1
Expand Down
36 changes: 28 additions & 8 deletions dlgr/griduniverse/static/scripts/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,13 @@ Player.prototype.replaceItem = function(item) {
if (item && !(item instanceof itemlib.Item)) {
item = new itemlib.Item(item.id, item.item_id, item.maturity, item.remaining_uses)
}
this.current_item = item;
this.currentItem = item;
displayWhatEgoPlayerIsCarrying(item);
};

Player.prototype.getTransition = function () {
var transition;
var player_item = this.current_item;
var player_item = this.currentItem;
alecpm marked this conversation as resolved.
Show resolved Hide resolved
var position = this.position;
var item_at_pos = gridItems.atPosition(position);
var transition_id = (player_item && player_item.itemId || '') + '|' + (item_at_pos && item_at_pos.itemId || '');
Expand Down Expand Up @@ -772,7 +772,7 @@ function bindGameKeys(socket) {
var ego = players.ego();
var position = ego.position;
var item_at_pos = gridItems.atPosition(position);
var player_item = ego.current_item;
var player_item = ego.currentItem;
var transition = ego.getTransition();
if (!item_at_pos && !player_item) {
// If there's nothing here, we try to plant food GU 1.0 style
Expand Down Expand Up @@ -811,8 +811,8 @@ function bindGameKeys(socket) {
Mousetrap.bind("d", function () {
var ego = players.ego();
var position = ego.position;
var current_item = ego.current_item;
if (!current_item || gridItems.atPosition(position)) {
var currentItem = ego.currentItem;
if (!currentItem || gridItems.atPosition(position)) {
return;
}
var msg = {
Expand All @@ -822,7 +822,7 @@ function bindGameKeys(socket) {
};
socket.send(msg);
ego.replaceItem(null);
gridItems.add(current_item, position);
gridItems.add(currentItem, position);
});

if (settings.mutable_colors) {
Expand Down Expand Up @@ -999,6 +999,7 @@ function renderTransition(transition) {
if (! transition) {
return "";
}
const transition_visibility = transition.transition.visible;
alecpm marked this conversation as resolved.
Show resolved Hide resolved
const states = [
transition.transition.actor_start,
transition.transition.actor_end,
Expand All @@ -1010,7 +1011,21 @@ function renderTransition(transition) {
(state) => settings.item_config[state]
);

return `✋${aStartItem.name} + ${tStartItem.name} → ✋${aEndItem.name} + ${tEndItem.name}`;
const aStartItemString = `✋${aStartItem ? aStartItem.name : '⬜'}`;
const tStartItemString = tStartItem ? tStartItem.name : '⬜';
if (transition_visibility == "never") {
return `${aStartItemString} + ${tStartItemString}`
}

if (transition_visibility == "seen" && !transitionsSeen.has(transition.id)) {
alecpm marked this conversation as resolved.
Show resolved Hide resolved
var aEndItemString = "✋❓";
var tEndItemString = "✋❓";
alecpm marked this conversation as resolved.
Show resolved Hide resolved
} else {
aEndItemString = `✋${aEndItem ? aEndItem.name: '⬜'}`;
tEndItemString = tEndItem ? tEndItem.name: '⬜';
}
return `${aStartItemString} + ${tStartItemString} → ${aEndItemString} + ${tEndItemString}`;

}
/**
* If the current player is sharing a grid position with an interactive
Expand All @@ -1032,7 +1047,12 @@ function updateItemInfoWindow(egoPlayer, gridItems) {
}

if (! transition) {
$transition.empty();
// If we're holding an item with calories, indicate that we might want to eat it.
if (egoPlayer.currentItem && egoPlayer.currentItem.calories) {
$transition.html(`✋${egoPlayer.currentItem.name} + 🤤`);
alecpm marked this conversation as resolved.
Show resolved Hide resolved
} else {
$transition.empty();
}
} else {
$transition.html(renderTransition(transition));
}
Expand Down
36 changes: 28 additions & 8 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.