Skip to content

Commit

Permalink
Implement transition visibility. Update some variable names. More com…
Browse files Browse the repository at this point in the history
…plex single player game by default.
  • Loading branch information
alecpm committed Aug 4, 2023
1 parent bb6bfc2 commit 1ad38b0
Show file tree
Hide file tree
Showing 9 changed files with 29,943 additions and 28,497 deletions.
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 @@ -246,13 +246,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;
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 @@ -773,7 +773,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 @@ -812,8 +812,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 @@ -823,7 +823,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 @@ -1001,6 +1001,7 @@ function renderTransition(transition) {
if (! transition) {
return "";
}
const transition_visibility = transition.transition.visible;
const states = [
transition.transition.actor_start,
transition.transition.actor_end,
Expand All @@ -1012,7 +1013,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)) {
var aEndItemString = "✋❓";
var tEndItemString = "✋❓";
} 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 @@ -1034,7 +1049,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} + 🤤`);
} else {
$transition.empty();
}
} else {
$transition.html(renderTransition(transition));
}
Expand Down
Loading

0 comments on commit 1ad38b0

Please sign in to comment.