瀏覽代碼

Enemy attacks now have conditions. Better description text handling.

tags/v0.2.8
Fen Dweller 7 年之前
父節點
當前提交
b14ecb17e5
共有 5 個檔案被更改,包括 35 行新增10 行删除
  1. +16
    -0
      combat.js
  2. +2
    -2
      feast.html
  3. +11
    -2
      feast.js
  4. +6
    -3
      vore.js
  5. +0
    -3
      world.js

+ 16
- 0
combat.js 查看文件

@@ -36,9 +36,25 @@ function devourPlayer(attacker) {
return { return {
name: "Devours YOU!", name: "Devours YOU!",
desc: "You won't see this", desc: "You won't see this",
conditions: [
function(prefs) { return prefs.player.prey; }
],
attackPlayer: function(defender) { attackPlayer: function(defender) {
changeMode("eaten"); changeMode("eaten");
return "The voracious " + attacker.description() + " pins you down and devours you in seconds."; return "The voracious " + attacker.description() + " pins you down and devours you in seconds.";
} }
} }
} }

function poke(attacker) {
return {
name: "Poke",
desc: "Poke a nerd",
attack: function(defender) {
return "You poke the " + defender.description() + " for " + attack(attacker, defender, 1e12) + " damage";
},
attackPlayer: function(defender) {
return "The " + attacker.description() + " pokes you on the snout for " + attack(attacker, defender, 1e12) + " damage";
}
};
}

+ 2
- 2
feast.html 查看文件

@@ -135,11 +135,11 @@
<ul id="character-form-list"> <ul id="character-form-list">
<li> <li>
<label for="character-name">Name</label> <label for="character-name">Name</label>
<input type="text" id="character-name" name="name"/>
<input type="text" id="character-name" name="name" placeholder="Player"/>
</li> </li>
<li> <li>
<label for="character-species">Species</label> <label for="character-species">Species</label>
<input type="text" id="character-species" name="species"/>
<input type="text" id="character-species" name="species" placeholder="nerd"/>
</li> </li>
<li> <li>
<label for="character-prefs-player-prey">Player can be eaten</label> <label for="character-prefs-player-prey">Player can be eaten</label>


+ 11
- 2
feast.js 查看文件

@@ -83,6 +83,7 @@ function updateEaten() {
button.innerHTML = currentFoe.struggles[i].name; button.innerHTML = currentFoe.struggles[i].name;
button.addEventListener("click", function() { struggleClicked(i); } ); button.addEventListener("click", function() { struggleClicked(i); } );
button.addEventListener("mouseover", function() { struggleHovered(i); } ); button.addEventListener("mouseover", function() { struggleHovered(i); } );
button.addEventListener("mouseout", function() { document.getElementById("eaten-desc").innerHTML = ""; } );
li.appendChild(button); li.appendChild(button);
list.appendChild(li); list.appendChild(li);
} }
@@ -102,6 +103,7 @@ function updateCombat() {
button.innerHTML = player.attacks[i].name; button.innerHTML = player.attacks[i].name;
button.addEventListener("click", function() { attackClicked(i); } ); button.addEventListener("click", function() { attackClicked(i); } );
button.addEventListener("mouseover", function() { attackHovered(i); } ); button.addEventListener("mouseover", function() { attackHovered(i); } );
button.addEventListener("mouseout", function() { document.getElementById("combat-desc").innerHTML = ""; } );
li.appendChild(button); li.appendChild(button);
list.appendChild(li); list.appendChild(li);
} }
@@ -223,7 +225,10 @@ function generateSettings() {
for (let i=0; i<form.length; i++) { for (let i=0; i<form.length; i++) {
let value = form[i].value == "" ? form[i].placeholder : form[i].value; let value = form[i].value == "" ? form[i].placeholder : form[i].value;
if (form[i].type == "text") if (form[i].type == "text")
settings[form[i].name] = value;
if (form[i].value == "")
settings[form[i].name] = form[i].placeholder;
else
settings[form[i].name] = value;
else if (form[i].type == "number") else if (form[i].type == "number")
settings[form[i].name] = parseFloat(value); settings[form[i].name] = parseFloat(value);
else if (form[i].type == "checkbox") { else if (form[i].type == "checkbox") {
@@ -306,7 +311,11 @@ function attackClicked(index) {
update(["The " + currentFoe.description() + " falls to the ground!"]); update(["The " + currentFoe.description() + " falls to the ground!"]);
startDialog(new FallenFoe(currentFoe)); startDialog(new FallenFoe(currentFoe));
} else { } else {
let attack = pick(currentFoe.attacks);
let attack = pick(currentFoe.attacks.filter(attack => attack.conditions == undefined || attack.conditions.reduce((result, test) => result && test(prefs), true)));

if (attack == null) {
attack = currentFoe.backupAttack;
}


update([attack.attackPlayer(player)]); update([attack.attackPlayer(player)]);




+ 6
- 3
vore.js 查看文件

@@ -1,5 +1,8 @@
function pick(list) { function pick(list) {
return list[Math.floor(Math.random()*list.length)];
if (list.length == 0)
return null;
else
return list[Math.floor(Math.random()*list.length)];
} }


function Creature(name = "Creature") { function Creature(name = "Creature") {
@@ -67,11 +70,11 @@ function Fen() {


this.attacks.push(new devourPlayer(this)); this.attacks.push(new devourPlayer(this));


this.backupAttack = new poke(this);

this.struggles = []; this.struggles = [];


this.struggles.push(new rub(this)); this.struggles.push(new rub(this));

this.conditions = [];
} }


function Micro() { function Micro() {


+ 0
- 3
world.js 查看文件

@@ -188,9 +188,6 @@ let locationsSrc = [
function() { function() {
startCombat(new Fen()); startCombat(new Fen());
} }
],
"conditions": [
function(prefs) { return prefs.player.prey; }
] ]
} }
]; ];


Loading…
取消
儲存