A Turn-based prototype
Prototyping here before sticking in to c#.
by Sam Fereday
HTML
<button id="start">
Start
</button>
JavaScript
/////////// === > Page 546
console.clear();
/// Script file names
// EV
var EV = function(obj) {
this.msg = obj.str;
};
EV.prototype.Create = function() {
this.mOwner = null;
this.mCountDown = -1;
}
EV.prototype.Execute = function() {};
EV.prototype.Update = function() {};
EV.prototype.IsFinished = function() {};
// Combat Events (asks what action wants to be taken, AI or manual for player)
// Combat Event Attack
var CEAttack = function(scene, owner, target) {
this.mScene = scene;
this.mOwner = owner;
this.mTarget = target;
this.mName = "CEAttack" + owner.mName + target.mName;
};
CEAttack.prototype.TimePoints = function(queue) {
let speed = this.mOwner.mSpeed;
return queue.SpeedToTimePoints(speed);
}
CEAttack.prototype.Execute = function(queue) {
let target = self.mTarget;
// Already dead?
if (target.mHP <= 0)
target = this.mScene.GetTarget(this.mOwner);
let damage = this.mOwner.mAttack;
target.mHP = target.mHP - damage;
console.log(target.mName + " hit for " + damage + "!");
if (target.mHP <= 0) {
console.log(target.mName + " is killed.");
this.mScene.OnDead(target);
}
}
CEAttack.prototype.Update = function() {}
CEAttack.prototype.IsFinished = function() {}
// A scene is what describes the combat state and actors involved.
var CETurn = function(scene, owner) {
this.mScene = scene;
this.mOwner = owner;
this.mName = "CETurn" + owner.mName;
console.log(this);
}
CETurn.prototype.TimePoints = function(queue) {
let speed = this.mOwner.mSpeed;
return queue.SpeedToTimePoints(speed);
}
CETurn.prototype.Execute = function(queue) {
// Choose random enemy target (we only really need the one currently but hey)
let target = this.mScene.GetTarget(this.mOwner);
console.log(this);
console.log(this.mOwner.mName + " decides to attack " + target.mName);
let _event = new CEAttack(this.mScene, this.mOwner, target);
let tp = _event.TimePoints(queue);
console.log("=====================",...