Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

endgame, tuning

  • Loading branch information...
commit 81ae3fda5ee4e47ea08dc383ca5c78f4ea01391f 1 parent 5682a77
ondras authored
View
4 TODO
@@ -1,4 +0,0 @@
-- endgame
-- attack power npcs
-- malby v hradu
-- druhy blocker v kostele
View
3  css/intro.css
@@ -48,3 +48,6 @@ body > * {
opacity: 0;
}
+#intro em {
+ font-family: droid sans mono;
+}
View
4 index.html
@@ -74,10 +74,10 @@
| |
| <span>Created by <a href="http://ondras.zarovi.cz/">Ondřej Žára</a></span> |
| <span>using <a href="http://ondras.github.com/rot.js/">rot.js</a></span> |
- | <span>hosted at <a href="https://github.com/ondras/trw">GitHub</a></span> |
+ | <span>forkable at <a href="https://github.com/ondras/trw">GitHub</a></span> |
____|______________________________________ |
\ \ /
- \__________________________________________\__/
+ \__________________________________________\__/ <em></em>
</pre>
<div id="text">
<div id="story">
View
3  js/common/being.js
@@ -175,6 +175,7 @@ Game.Being.prototype.attack = function(target) {
/* FIXME probably refactor to a dedicated attack logic? */
/* 1. hit? */
+// console.log("hit", this.getAttackSpeed(), "+5", "vs", target.getDefenseSpeed());
var speed1 = this.getAttackSpeed() + ROT.RNG.getNormal(5, 5); /* attacker advantage */
var speed2 = target.getDefenseSpeed() + ROT.RNG.getNormal(0, 5);
@@ -187,6 +188,7 @@ Game.Being.prototype.attack = function(target) {
/* 1b. hit */
var dmg = this.getDamage() + ROT.RNG.getNormal(0, 1);
var pv = target.getPV() + ROT.RNG.getNormal(0, 1);
+// console.log("dmg", this.getDamage(), "vs", target.getPV());
dmg = Math.round(dmg-pv);
/* 2a. not enough damage */
@@ -196,6 +198,7 @@ Game.Being.prototype.attack = function(target) {
}
/* 2b. damage */
+// console.log("dmg dealt", dmg);
target.adjustHP(-dmg);
var str = "%The %{verb,hit} %the".format(this, this, target);
var ratio = target.getHP() / target.getMaxHP();
View
18 js/common/lib/beings.js
@@ -23,6 +23,7 @@ Game.Beings.define("dog", {
Game.Beings.define("rat", {
extend: "animal",
+ speed: 105,
name: "rat",
color: [160, 160, 160],
"char": "r"
@@ -52,6 +53,7 @@ Game.Beings.define("orc", {
"char": "o",
name: "orc",
hp: 3,
+ damage: 2,
extend: "humanoid",
color: [30, 240, 30]
});
@@ -60,6 +62,7 @@ Game.Beings.define("goblin", {
"char": "g",
name: "goblin",
hp: 2,
+ damage: 2,
extend: "humanoid",
color: [30, 30, 240]
});
@@ -68,6 +71,7 @@ Game.Beings.define("kobold", {
"char": "k",
name: "kobold",
hp: 2,
+ damage: 2,
extend: "humanoid",
color: [30, 240, 30]
});
@@ -75,7 +79,10 @@ Game.Beings.define("kobold", {
Game.Beings.define("orc chieftain", {
extend: "orc",
name: "orc chieftain",
- hp: 4,
+ hp: 5,
+ speed: 110,
+ pv: 2,
+ damage: 3,
"char": "O"
}, {
level: 2
@@ -84,7 +91,10 @@ Game.Beings.define("orc chieftain", {
Game.Beings.define("goblin chieftain", {
extend: "goblin",
name: "goblin chieftain",
- hp: 4,
+ hp: 5,
+ speed: 110,
+ pv: 2,
+ damage: 2,
color: [30, 30, 160]
}, {
level: 2
@@ -100,6 +110,8 @@ Game.Beings.define("skeleton", {
extend: "undead",
name: "skeleton",
hp: 2,
+ damage: 2,
+ speed: 105,
"char": "s",
color: [220, 220, 220]
}, {
@@ -110,6 +122,8 @@ Game.Beings.define("zombie", {
extend: "undead",
name: "zombie",
hp: 2,
+ speed: 105,
+ damage: 2,
"char": "z",
color: [150, 200, 30]
}, {
View
9 js/game.js
@@ -100,13 +100,16 @@ var Game = {
_start: function(e) {
window.addEventListener("resize", this);
+/*
this.storyFlags.nightEnded = 1;
this.storyFlags.gardenerDead = 1;
- Game.LevelManager.get("castle").then(function(level) {
+*/ Game.LevelManager.get("forest").then(function(level) {
this.switchLevel(level);
}.bind(this));
-//var d = new Game.Level.Dungeon(1);
-//this.switchLevel(d, "start", "fade");
+/*
+ var d = new Game.Level.Dungeon(1);
+ this.switchLevel(d, "start", "fade");
+*/
},
_resize: function() {
View
6 js/lib/beings.js
@@ -12,6 +12,9 @@ Game.Beings.define("player", {
Game.Beings.define("guard", {
extend: "humanoid",
name: "guard",
+ speed: 110,
+ damage: 3,
+ hp: 3,
sex: 1,
tasks: [],
color: [220, 140, 140]
@@ -33,6 +36,9 @@ Game.Beings.define("gardener", {
extend: "humanoid",
name: "gardener",
sex: 1,
+ hp: 3,
+ speed: 115,
+ damage: 3,
chats: ["Good day to you, sir!", "Watch these flowers blossom!", "This garden needs my attention."],
color: [100, 240, 100],
}, {
View
6 js/lib/bride.js
@@ -4,7 +4,11 @@ Game.Being.Bride = function(type) {
Game.Being.Bride.extend(Game.Being);
Game.Being.Bride.prototype.chat = function(being) {
- Game.status.show("%He sits in the corner and sobs quietly.".format(this));
+ if (Game.storyFlags.gardenerDead) {
+
+ } else {
+ Game.status.show("%He sits in the corner and sobs quietly.".format(this));
+ }
}
Game.Being.Bride.prototype.getSpeed = function() {
View
37 js/player.js
@@ -1,4 +1,5 @@
Game.Player = function(type) {
+ this._ended = false;
// this._debug = true;
Game.Being.call(this, type);
@@ -8,6 +9,7 @@ Game.Player = function(type) {
this._secretGold = 0;
this._gold = 0;
this._gems = 0;
+ this._turns = 0;
this._knownTypes = [];
@@ -40,6 +42,7 @@ Game.Player = function(type) {
Game.Player.extend(Game.Being);
Game.Player.prototype.act = function() {
+ this._turns++;
this._level.updateLighting(); /* FIXME urco? */
Game.legend.update(this._position[0], this._position[1]);
Game.engine.lock();
@@ -59,6 +62,10 @@ Game.Player.prototype.handleEvent = function(e) {
}
Game.Player.prototype._handleKey = function(code) {
+ if (this._ended) {
+ this._endGame();
+ return true;
+ }
if (code in this._directionKeys) {
Game.status.clear();
@@ -121,6 +128,8 @@ Game.Player.prototype._tryMovingTo = function(x, y) {
if (being) { /* being - chat or fight */
if (being.isHostile()) {
this.attack(being);
+ } else if (being.getType() == "bride" && Game.storyFlags.gardenerDead) {
+ this._victory(being);
} else {
this._chat(being);
}
@@ -258,3 +267,31 @@ Game.Player.prototype.describeThe = function() {
Game.Player.prototype.describeHim = function() {
return "you";
}
+
+Game.Player.prototype._victory = function(being) {
+ Game.status.show("You slowly approach the bride. She tries to step backwards...");
+ Game.status.show("<br/><br/>");
+ Game.status.show("...but her foot slips over the wet pier and she falls right into the deep water!");
+ Game.status.show("<br/><br/>");
+ Game.status.show("(press any key to continue)");
+
+ this._level.removeBeing(being);
+ Game.engine.removeActor(being);
+ this._ended = true;
+}
+
+Game.Player.prototype._endGame = function() {
+ Game.engine.lock();
+
+ Game.story.newChapter("My story ends right here: the justice has been served and I have been spared of making moral decisions. Win-win!")
+ Game.story.addChapter("(The game ends as well; hope you enjoyed it!)")
+
+ Game.status.clear();
+ Game.status.show("Achievements:<br/><br/>");
+ Game.status.show(this._gold + " gold found<br/>");
+ Game.status.show(this._secretGold + " secret gold stashes found<br/>");
+ Game.status.show(this._gems + " precious gems found<br/>");
+ Game.status.show(this._kills + " enemies killed<br/>");
+ Game.status.show(this._turns + " turns played");
+
+}
View
2  levels/castle.js
@@ -73,7 +73,7 @@ Game.Level.Castle.prototype._initStory = function() {
var key = Game.player.getPosition().join(",");
return (this.cells[key].getId() == "throneroom");
}, function() {
- Game.story.newChapter("The throne room is empty as well - and locked, too. How am I supposed to get into the chapel through all those locked doors? Perhaps that funny jester will provide an answer.");
+ Game.story.newChapter("The throne room is empty as well. How am I supposed to get into the chapel through all those locked doors? Perhaps that funny jester will provide an answer.");
return true;
});
View
19 levels/castle.txt
@@ -1,7 +1,7 @@
-T========w# ###############
-T======www# ########## #$===========T#
-T====M=w### #........# ### ################======#
+T========w# #############
+T======www# ########## ###$=========T#
+T====M=w### #........# ### #########P######======#
T======w#G####1######+#####^#########^.........J..^#======#
T======w#-#______###p..............##......##.....s#=T==ff#
T======w--|_______#.....##...##.....#......##......#====ff#
@@ -9,8 +9,8 @@ T====-bBb-|_______L.................2............t.#==W=ff#
T=---==w--|_______#.....##...##.....#......##......#====ff#
6@=====w#-#______###...............##......##.....s#====ff#
T======w#G####L######L#####^#########^............^#======#
-T======w### #r......###s.xyz.s#######\########======#
-T======www# #r........4..........3....#========T====#
+T======w### #r......###s.xyz.s#######\#P######======#
+T======www# #r........4..........3....###======T====#
T==d=====w# #r......###s.....s#########===========ff#
T========w## #.#################==========------===ff#
T========ww# #................!+----------======-==ff#
@@ -45,6 +45,15 @@ T==========w# ##################5####
"color": [80, 80, 80]
}
},
+ "P": {
+ "cell": {
+ "type": "stonewall",
+ "name": "painting",
+ "char": "=",
+ "color": [180, 180, 180],
+ "colorVariation": [50, 50, 50]
+ }
+ },
"\\": {
"cell": {
"type": "stonewall",
View
13 levels/chapel.js
@@ -87,8 +87,8 @@ Game.Level.Chapel.prototype._murderGroom = function() {
for (var i=0;i<ROT.DIRS[8].length;i++) {
var x = pos[0] + ROT.DIRS[8][i][0];
var y = pos[1] + ROT.DIRS[8][i][1];
- var item = this.items[x+","+y];
- if (!item && ROT.RNG.getUniform() > 0.5) {
+ var cell = this.cells[x+","+y];
+ if (cell.getType() == "floor" && ROT.RNG.getUniform() > 0.5) {
this.setCell(Game.Cells.create("blood"), x, y);
}
}
@@ -113,6 +113,15 @@ Game.Level.Chapel.prototype._murderGroom = function() {
guest.setChats(["Have you seen it? The groom has been stabbed!", "They say that the groom has been murdered!", "A hooded figure suddenly appeared and killed the groom!", "Oh my god oh my god!", "He jumped out right through that window!"]);
}
+ var pos = this._priest.getPosition();
+ var x = pos[0]-2;
+ var y = pos[1];
+ var being = this.beings[x+","+y];
+ if (being) {
+ Game.engine.removeActor(being);
+ this.removeBeing(being);
+ }
+ this.setBeing(this._priest, x, y);
this._priest.setChats(["The groom is dead! His murderer jumped out of the chapel window; please try to follow him as fast as possible!"]);
var pos = this.getCellById("bride").getPosition();
View
9 levels/chapel.txt
@@ -11,7 +11,7 @@
==---==#.......................................P....2###=====
===----/.........|g|.|g|.|g|.|g|.|g|.|g|.|.....±B......##====
=====--/.........|g|.|g|.|g|.|g|.|g|.|g|.|.....±G......##====
-=======#.............................................###=====
+=======#.......................................Y.....###=====
=======#....##..##..##..##..##..##..######//##########=======
=======#..............................#........#======+======
=======#....................................±..#=========+===
@@ -96,6 +96,13 @@
"name": "stained glass window"
}
},
+ "Y": {
+ "cell": {
+ "type": "statue",
+ "name": "religious statue",
+ "color": [180, 180, 180]
+ }
+ },
"g": {
"cell": "floor",
"being": "guest"
View
2  levels/dungeon.js
@@ -1,7 +1,7 @@
Game.Level.Dungeon = function(depth, previousLevel, previousCell) {
Game.Level.call(this);
this._depth = depth;
- this._maxDepth = 1;
+ this._maxDepth = 3;
this._gardener = null;
if (this._depth == this._maxDepth) {
this._gardener = Game.Beings.create("gardener");
View
1  levels/forest.js
@@ -100,6 +100,7 @@ Game.Level.Forest.prototype._initStory = function() {
this.setBeing(bride, pos[0]-2, pos[1]);
Game.engine.addActor(bride);
+
return true;
});
}
Please sign in to comment.
Something went wrong with that request. Please try again.