Skip to content

Commit

Permalink
Add global.js to store strings
Browse files Browse the repository at this point in the history
  • Loading branch information
dirmeier committed May 1, 2020
1 parent d5eb88e commit 5ce2671
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 65 deletions.
29 changes: 29 additions & 0 deletions app/global.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"use strict";

define(function () {
return {
agora: {name: "Agora", path: "app/view/agora.jpeg"},
alcibiades: {name: "Alcibiades", path: "app/view/alcibiades.jpeg"},
barrel: {name: "Diogenes' barrel", path: "app/view/barrel.jpeg"},
bouleuterion: {name: "Bouleuterion", path: "app/view/bouleuterion.jpeg"},
bow: {name: "Bow", path: "app/view/bow.png"},
charmides: {name: "Charmides", path: "app/view/charmides.jpeg"},
critias: {name: "Critias", path: "app/view/critias.jpeg"},
dagger: {name: "Dagger", path: "app/view/dagger.png"},
heraclitus: {name: "Heraclitus", path: "app/view/heraclitus.jpeg"},
hill: {name: "Hill of the Muses", path: "app/view/hill.jpeg"},
library: {name: "Library", path: "app/view/library.jpeg"},
lysander: {name: "Lysander", path: "app/view/lysander.jpeg"},
parthenon: {name: "Parthenon", path: "app/view/parthenon.jpeg"},
plato: {name: "Plato", path: "app/view/plato.jpeg"},
poison: {name: "Cup of poison", path: "app/view/poison.jpeg"},
rope: {name: "Rope", path: "app/view/rope.jpeg"},
sickle: {name: "Sickle", path: "app/view/sickle.jpeg"},
socrates: {name: "Socrates", path: "app/view/socrates.jpeg"},
temple: {name: "Temple", path: "app/view/temple.jpeg"},
theater: {name: "Theater", path: "app/view/theater.jpeg"},
treachery: {name: "Treachery", path: "app/view/treachery.png"},
tree: {name: "Socrates' favourite olive tree", path: "app/view/tree.jpeg"}
};
});

31 changes: 16 additions & 15 deletions app/model/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

define(function (require) {
const utl = require("util");
const glb = require("global");

const Tile = require("model/board/tile");
const Place = require("model/board/place");
Expand All @@ -12,25 +13,25 @@ define(function (require) {
const legend = require("model/board/board_legend");

const suspects = [
new Suspect("Plato", "red", "app/view/plato.jpeg"),
new Suspect("Critias", "green", "app/view/critias.jpeg"),
new Suspect("Alcibiades", "yellow", "app/view/alcibiades.jpeg"),
new Suspect("Heraclitus", "purple", "app/view/heraclitus.jpeg"),
new Suspect("Charmides", "blue", "app/view/charmides.jpeg"),
new Suspect("Lysander", "orange", "app/view/lysander.jpeg")
].sort();
new Suspect(glb.alcibiades.name, glb.alcibiades.path),
new Suspect(glb.charmides.name, glb.charmides.path),
new Suspect(glb.critias.name, glb.critias.path),
new Suspect(glb.heraclitus.name, glb.heraclitus.path),
new Suspect(glb.lysander.name, glb.lysander.path),
new Suspect(glb.plato.name, glb.plato.path)
];

const weapons = [
new Weapon("Cup of poison", "green", "app/view/poison.jpeg"),
new Weapon("Dagger", "purple", "app/view/dagger.png"),
new Weapon("Treachery", "red", "app/view/treachery.png"),
new Weapon("Sickle", "black", "app/view/sickle.jpeg"),
new Weapon("Rope", "brown", "app/view/rope.jpeg"),
new Weapon("Bow", "yellow", "app/view/bow.png")
].sort();
new Weapon(glb.bow.name, glb.bow.path),
new Weapon(glb.dagger.name, glb.dagger.path),
new Weapon(glb.poison.name, glb.poison.path),
new Weapon(glb.rope.name, glb.rope.path),
new Weapon(glb.sickle.name, glb.sickle.path),
new Weapon(glb.treachery.name, glb.treachery.path)
];

class Board {
constructor(nSuspects) {
constructor() {
this._weapons = Array.from(weapons);
this._suspects = Array.from(suspects);
this._places = this._initPlaces();
Expand Down
2 changes: 1 addition & 1 deletion app/model/board/board.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"uBe Btrict";
"use strict";

define(function () {
return [
Expand Down
37 changes: 24 additions & 13 deletions app/model/board/board_legend.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,73 @@
"use strict";

define(function () {
define(function (require) {
const glb = require("global");

return [
{
"legend": "A",
"place": "Agora",
"place": glb.agora.name,
"type": "place",
"path": "app/view/agora.jpeg"
},
{
"legend": "B",
"place": "Bouleuterion",
"place": glb.bouleuterion.name,
"type": "place",
"path": "app/view/bouleuterion.jpeg"
},
{
"legend": "D",
"place": "Diogenes' barrel",
"place": glb.barrel.name,
"type": "place",
"path": "app/view/barrel.jpeg"
},
{
"legend": "H",
"place": "Hill of the Muses",
"place": glb.hill.name,
"type": "place",
"path": "app/view/hill.jpeg"
"path": glb.hill.path
},
{
"legend": "L",
"place": "Library",
"place": glb.library.name,
"type": "place",
"path": "app/view/library.jpeg"
},
{
"legend": "P",
"place": "Parthenon",
"place": glb.parthenon.name,
"type": "place",
"path": "app/view/parthenon.jpeg"
},
{
"legend": "S",
"place": "Socrates' favourite olive tree",
"place": glb.tree.name,
"type": "place",
"path": "app/view/tree.jpeg"
},
{
"legend": "T",
"place": "Theater",
"place": glb.theater.name,
"type": "place",
"path": "app/view/theater.jpeg"
},
{
"legend": "U",
"place": "Temple",
"place": glb.temple.name,
"type": "place",
"path": "app/view/temple.jpeg"
},
{"legend": "_", "place": "_", "type": "other", "path": "app/view/socrates.jpeg"},
{"legend": ".", "place": "_", "type": "path"}
{
"legend": "_",
"place": "_",
"type": "other",
"path": "app/view/socrates.jpeg"
},
{
"legend": ".",
"place": "_",
"type": "path"
}
];
});
7 changes: 1 addition & 6 deletions app/model/board/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@
define(function () {
return {
Item: class Item {
constructor(name, color, path) {
constructor(name, path) {
this._name = name;
this._color = color;
this._tile = null;
this._path = path;
}

get color() {
return this._color;
}

get name() {
return this._name;
}
Expand Down
4 changes: 2 additions & 2 deletions app/model/board/suspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ define(function (require) {
const Item = require("model/board/item");

class Suspect extends Item.Item {
constructor(name, color, path) {
super(name, color, path);
constructor(name, path) {
super(name, path);
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/model/board/weapon.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ define(function (require) {
const Item = require("model/board/item");

class Weapon extends Item.Item {
constructor(name, color, path) {
super(name, color, path);
constructor(name, path) {
super(name, path);
}
}

Expand Down
45 changes: 23 additions & 22 deletions app/model/cards.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"use strict";

define(function(require) {
define(function (require) {
const utl = require("util");
const glb = require("global");

const Suspect = require("model/cards/suspect");
const Weapon = require("model/cards/weapon");
Expand All @@ -10,33 +11,33 @@ define(function(require) {
const victim = new Suspect("Socrates");

const suspects = [
new Suspect("Charmides"),
new Suspect("Alcibiades"),
new Suspect("Heraclitus"),
new Suspect("Critias"),
new Suspect("Lysander"),
new Suspect("Plato")
new Suspect(glb.alcibiades.name, glb.alcibiades.path),
new Suspect(glb.charmides.name, glb.charmides.path),
new Suspect(glb.critias.name, glb.critias.path),
new Suspect(glb.heraclitus.name, glb.heraclitus.path),
new Suspect(glb.lysander.name, glb.lysander.path),
new Suspect(glb.plato.name, glb.plato.path)
];

const weapons = [
new Weapon("Bow"),
new Weapon("Cup of poison"),
new Weapon("Sickle"),
new Weapon("Dagger"),
new Weapon("Rope"),
new Weapon("Treachery")
new Weapon(glb.bow.name, glb.bow.path),
new Weapon(glb.dagger.name, glb.dagger.path),
new Weapon(glb.poison.name, glb.poison.path),
new Weapon(glb.rope.name, glb.rope.path),
new Weapon(glb.sickle.name, glb.sickle.path),
new Weapon(glb.treachery.name, glb.treachery.path)
];

const places = [
new Place("Agora"),
new Place("Bouleuterion"),
new Place("Diogenes' barrel"),
new Place("Hill of the Muses"),
new Place("Library"),
new Place("Panthenon"),
new Place("Sitting rock under a tree"),
new Place("Temple"),
new Place("Theater")
new Place(glb.agora.name, glb.agora.path),
new Place(glb.barrel.name, glb.barrel.path),
new Place(glb.bouleuterion.name, glb.bouleuterion.path),
new Place(glb.hill.name, glb.hill.path),
new Place(glb.library.name, glb.library.path),
new Place(glb.parthenon.name, glb.parthenon.path),
new Place(glb.temple.name, glb.temple.path),
new Place(glb.theater.name, glb.theater.path),
new Place(glb.tree.name, glb.tree.path)
];

class Cards {
Expand Down
6 changes: 5 additions & 1 deletion app/model/cards/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

define(function () {
class Card {
constructor(name) {
constructor(name, path) {
this._name = name;
this._path = path
}

get name() {
return this._name;
}
get path() {
return this._path;
}
}

Card.prototype.toString = function () {
Expand Down
3 changes: 0 additions & 3 deletions app/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ define(function (require) {
ul.selectAll("li").remove();
for (let piece of arr) {
if (piece.name === "_") continue;
//const tile = piece.tile;
ul.append("li")
.append("span")
.text(piece.name + " ")
Expand All @@ -255,8 +254,6 @@ define(function (require) {
}
}



_initButtonDescription() {
d3.select('#legend')
.append('h5')
Expand Down
Binary file removed app/view/altar.jpeg
Binary file not shown.

0 comments on commit 5ce2671

Please sign in to comment.