Jack's simplified game replicating Taipan!
It's one of old school turn based strategy gmams in 80s
by Jack 0
HTML
<p id="top"></p>
<hr>
<p id="center"></p>
<hr>
<p>What do you want to do, <strong><em>Taipan</em></strong>? <strong>B</strong>uy? <strong>S</strong>ell? <strong>M</strong>ove? <strong>Q</strong>uit?</p>
<img src="http://xjlin0.github.io/blog/imgs/shipb.gif"/>
<!-- https://gist.github.com/xem/670dec8e70815842eb95 -->
<button onclick="new Audio('data:audio/wav;base64,UklGRl9vT19XQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YU'+Array(3).join(1234567)).play()">Beep</button>
<button onclick="with(o=(A=new AudioContext).createOscillator()){connect(A.destination);start(0);s=stop||noteOff;setTimeout('o.stop(0.1)',50)}">Boop</button>
JavaScript
var playerShip = { //define player properties;
cargo: {
opium: 0, silk: 0,
arms: 0, general: 0,
total: function(){ return this.opium +
this.silk + this.arms + this.general;}
},
status: {
capacity: 60, guns: 3,
seaworthiness: 100, money: 200,
shipHold: function(){return this.capacity - this.guns*10 - playerShip.cargo.total();}
},
wareHouse: {
opium: 0, silk: 0,
arms: 0, general: 0,
capacity: 10000,
total: function(){ return this.opium +
this.silk + this.arms + this.general;}
},
brotherWu: 0,
bankAccount: 0,
getBattleRate: 0,
battled: 0,
currentLocation: "Hong Kong"
};
// define city names
var cities = {
1: "Hong Kong", 2: "Shanghai", 3: "Nagasaki",
4: "Saigon", 5: "Manila", 6: "Singapore",
7: "Batavia", 8: "Krung Thep"
};
// define city properties
function City(name){
this.name = name;
this.goods = ["opium","silk","arms","general"];
this.price = {
opium: Math.floor( Math.random() * ( 40000-4000))+4000,
silk : Math.floor( Math.random() * ( 4000- 400))+400,
arms : Math.floor( Math.random() * ( 400 - 40 ))+40,
general : Math.floor( Math.random() * ( 40 - 3 ))+3
};
this.event = {
liYuen: 0,
fixer:Math.random(),
updater: Math.random(),
fluctuation: Math.random(),
police: Math.random()
};
}
// top local city menu
function topM(){
var topMenu = "<h3>It's Asia in 19 century, we're boarding at "+city.name+", ";
topMenu += "the price of local goods are:</h3><p>";
for (var goods in city.price) {
topMenu += "<strong>" + goods + "</strong>: $"+city.price[goods]+" per unit.<br>";
}
return topMenu;
}
//center ship status menu
function shipM(){
var shipMenu = "<h3>Aye aye, sir! reporting the status, our ship is currently holding:</h3><p>";
for (var goods in playerShip.cargo) {
...