var s_sliderValues = new Array(); window.addEvent('domready', function(){ // read fates for (i = 0; i < 8; i++) { var value = STORE["fate" + i + "_cost"]; var elem = $("FATE_COST_" + i); elem.set('class', "circlesSmall circlesSmall" + value); s_sliderValues[elem.id] = value; } UpdateTotalFateCost(); // skills var value = STORE["Unarmed_Combat"]; var elem = $(ATTR_Unarmed_Combat); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Wormcharm"]; var elem = $(ATTR_Wormcharm); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Movement"]; var elem = $(ATTR_Movement); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Melee_Weapons"]; var elem = $(ATTR_Melee_Weapons); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Evasion"]; var elem = $(ATTR_Evasion); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Stealth"]; var elem = $(ATTR_Stealth); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Ninjutsi"]; var elem = $(ATTR_Ninjutsi); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Criminal_Arts"]; var elem = $(ATTR_Criminal_Arts); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["First_Aid"]; var elem = $(ATTR_First_Aid); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Notice"]; var elem = $(ATTR_Notice); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Marksman"]; var elem = $(ATTR_Marksman); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Pursuit_OR_Hunt"]; var elem = $(ATTR_Pursuit_OR_Hunt); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Forgery"]; var elem = $(ATTR_Forgery); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Information"]; var elem = $(ATTR_Information); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Onmyojustu"]; var elem = $(ATTR_Onmyojustu); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Willpower"]; var elem = $(ATTR_Willpower); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Resonance"]; var elem = $(ATTR_Resonance); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Interface"]; var elem = $(ATTR_Interface); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Buddhist_Magic"]; var elem = $(ATTR_Buddhist_Magic); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Pursuasion"]; var elem = $(ATTR_Pursuasion); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Pillow_Arts"]; var elem = $(ATTR_Pillow_Arts); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Perform"]; var elem = $(ATTR_Perform); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Strategy"]; var elem = $(ATTR_Strategy); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Etiquette"]; var elem = $(ATTR_Etiquette); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Shinto"]; var elem = $(ATTR_Shinto); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; var value = STORE["Art_of_Rule"]; var elem = $(ATTR_Art_of_Rule); elem.set('class', "circlesBig circlesBig" + value); s_sliderValues[elem.id] = value; // Karma UpdateKarma(); $('KARMA_MEIKYO').addEvent('change', function(event) { UpdateKarma(); }); $('KARMA_PLAYER').addEvent('change', function(event) { UpdateKarma(); }); $('KARMA').addEvent('change', function(event) { // assume player karma karma = parseInt(this.get("value")); meikyoKarma = parseInt($('KARMA_MEIKYO').get("value")); $('KARMA_PLAYER').set("value", karma - meikyoKarma); CheckForErrors(); }); // Vitality $('SKILL_Body').addEvent('change', function(event) { UpdateMaxVit(); }); $('SKILL_Spirit').addEvent('change', function(event) { UpdateMaxVit(); UpdateMaxSoul(); }); $('SKILL_Knowledge').addEvent('change', function(event) { UpdateMaxSoul(); }); UpdateMaxVit(); UpdateMaxSoul(); for (i = 0; i < 20; i++) { var elem = $("WOUND_LIGHT_" + i); elem.woundIndex = i; elem.addEvent("mousedown", function(event) { event.stop(); if (event.rightClick) ClearWounds("woundsLight", "WOUND_LIGHT_", 20); else SetWounds(this.woundIndex, "woundsLight", "WOUND_LIGHT_", 20); }); elem.addEvent("contextmenu", function(event) { return false; }); if (i < STORE["woundsLight"]) { elem.addClass("blockChecked"); } } for (i = 0; i < 10; i++) { var elem = $("WOUND_HEAVY_" + i); elem.woundIndex = i; elem.addEvent("mousedown", function(event) { event.stop(); if (event.rightClick) ClearWounds("woundsHeavy", "WOUND_HEAVY_", 10); else SetWounds(this.woundIndex, "woundsHeavy", "WOUND_HEAVY_", 10); }); elem.addEvent("contextmenu", function(event) { return false; }); if (i < STORE["woundsHeavy"]) { elem.addClass("blockChecked"); } } for (i = 0; i < 5; i++) { var elem = $("WOUND_CRIT_" + i); elem.woundIndex = i; elem.addEvent("mousedown", function(event) { event.stop(); if (event.rightClick) ClearWounds("woundsCrit", "WOUND_CRIT_", 5); else SetWounds(this.woundIndex, "woundsCrit", "WOUND_CRIT_", 5); }); elem.addEvent("contextmenu", function(event) { return false; }); if (i < STORE["woundsCrit"]) { elem.addClass("blockChecked"); } } var elem = $("WOUND_DEAD"); elem.addEvent("mousedown", function(event) { event.stop(); if (event.rightClick) ClearDead(); else SetDead(); }); elem.addEvent("contextmenu", function(event) { return false; }); if (STORE["dead"] == 1) { elem.addClass("blockChecked"); } s_sliderValues["woundsLight"] = STORE["woundsLight"]; s_sliderValues["woundsHeavy"] = STORE["woundsHeavy"]; s_sliderValues["woundsCrit"] = STORE["woundsCrit"]; s_sliderValues["dead"] = STORE["dead"]; UpdatesWounds(); $$(".circlesSmall").addEvent("mousedown", function(event) { event.stop(); var position = this.getPosition(); var value = Math.ceil((event.client.x - position.x)/ 7); if (value > 5) value = 5; else if (value < 1) value = 1; this.set('class', "circlesSmall circlesSmall" + value); s_sliderValues[this.id] = value; UpdateTotalFateCost(); }); $$(".circlesBig").addEvent("mousedown", function(event) { event.stop(); var position = this.getPosition(); var value = Math.ceil((event.client.x - position.x)/ 13); if (value > 5) value = 5; else if (value < 1) value = 1; this.set('class', "circlesBig circlesBig" + value); s_sliderValues[this.id] = value; }); $("BTN_SAVE").addEvent("click", function(event) { event.stop(); Save(); }); $("BTN_LOAD").addEvent("click", function(event) { event.stop(); Load(); }); }); function Save () { var req = "version=1&"; req += "name=" + $("NAME").get("value") + "&"; req += "age=" + $("AGE").get("value") + "&"; req += "sex=" + $("SEX").get("value") + "&"; req += "concept=" + $("CONCEPT").get("value") + "&"; req += "karmaCost=" + $("KARMA_COST").get("value") + "&"; req += "attrCost=" + $("ATTR_COST").get("value") + "&"; req += "vitality=" + $("VITALITY").get("value") + "&"; req += "vitalityMax=" + $("VITALITY_MAX").get("value") + "&"; req += "soul=" + $("SOUL").get("value") + "&"; req += "soulMax=" + $("SOUL_MAX").get("value") + "&"; req += "kiai=" + $("KIAI_CUR").get("value") + "&"; req += "kiaiSpent=" + $("KIAI_SPENT").get("value") + "&"; req += "karmaPlayer=" + $("KARMA_PLAYER").get("value") + "&"; req += "karmaMeikyo=" + $("KARMA_MEIKYO").get("value") + "&"; // fates for (i = 0; i < 8; i++) { req += "fate" + i +"=" + $("FATE_" + i).get("value") + "&"; req += "fate" + i +"_cost=" + s_sliderValues["FATE_COST_" + i] + "&"; } req += "woundsLight=" + s_sliderValues["woundsLight"] + "&"; req += "woundsHeavy=" + s_sliderValues["woundsHeavy"] + "&"; req += "woundsCrit=" + s_sliderValues["woundsCrit"] + "&"; req += "dead=" + s_sliderValues["dead"] + "&"; // skills req += "Body=" + $("SKILL_Body").get("value") + "&"; req += "Body_V=" + $("SKILL_Body_V").get("value") + "&"; req += "Unarmed_Combat=" + s_sliderValues["ATTR_Unarmed_Combat"] + "&"; req += "Wormcharm=" + s_sliderValues["ATTR_Wormcharm"] + "&"; req += "Agility=" + $("SKILL_Agility").get("value") + "&"; req += "Agility_V=" + $("SKILL_Agility_V").get("value") + "&"; req += "Movement=" + s_sliderValues["ATTR_Movement"] + "&"; req += "Melee_Weapons=" + s_sliderValues["ATTR_Melee_Weapons"] + "&"; req += "Evasion=" + s_sliderValues["ATTR_Evasion"] + "&"; req += "Stealth=" + s_sliderValues["ATTR_Stealth"] + "&"; req += "Ninjutsi=" + s_sliderValues["ATTR_Ninjutsi"] + "&"; req += "Criminal_Arts=" + s_sliderValues["ATTR_Criminal_Arts"] + "&"; req += "Senses=" + $("SKILL_Senses").get("value") + "&"; req += "Senses_V=" + $("SKILL_Senses_V").get("value") + "&"; req += "First_Aid=" + s_sliderValues["ATTR_First_Aid"] + "&"; req += "Notice=" + s_sliderValues["ATTR_Notice"] + "&"; req += "Marksman=" + s_sliderValues["ATTR_Marksman"] + "&"; req += "Pursuit_OR_Hunt=" + s_sliderValues["ATTR_Pursuit_OR_Hunt"] + "&"; req += "Forgery=" + s_sliderValues["ATTR_Forgery"] + "&"; req += "Knowledge=" + $("SKILL_Knowledge").get("value") + "&"; req += "Information=" + s_sliderValues["ATTR_Information"] + "&"; req += "Onmyojustu=" + s_sliderValues["ATTR_Onmyojustu"] + "&"; req += "Spirit=" + $("SKILL_Spirit").get("value") + "&"; req += "Willpower=" + s_sliderValues["ATTR_Willpower"] + "&"; req += "Resonance=" + s_sliderValues["ATTR_Resonance"] + "&"; req += "Interface=" + s_sliderValues["ATTR_Interface"] + "&"; req += "Buddhist_Magic=" + s_sliderValues["ATTR_Buddhist_Magic"] + "&"; req += "Empathy=" + $("SKILL_Empathy").get("value") + "&"; req += "Pursuasion=" + s_sliderValues["ATTR_Pursuasion"] + "&"; req += "Pillow_Arts=" + s_sliderValues["ATTR_Pillow_Arts"] + "&"; req += "Perform=" + s_sliderValues["ATTR_Perform"] + "&"; req += "Station=" + $("SKILL_Station").get("value") + "&"; req += "Strategy=" + s_sliderValues["ATTR_Strategy"] + "&"; req += "Etiquette=" + s_sliderValues["ATTR_Etiquette"] + "&"; req += "Shinto=" + s_sliderValues["ATTR_Shinto"] + "&"; req += "Art_of_Rule=" + s_sliderValues["ATTR_Art_of_Rule"] + "&"; // weapons for (i = 0; i < 4; i++) { req += "weapon" + i +"=" + $("WEAPON_" + i).get("value") + "&"; } req += "possessions=" + $("POSSESSIONS").get("value") + "&"; //alert(req); var saveRequest = new Request.HTML({url: 'php/save.php'}).post( req ); } function Load () { var url = window.location.href; var end = url.indexOf("?"); if (end > 0) url = url.slice(0, end); url +="?name=" + $("NAME").get("value"); window.location.replace(url); } function Cheer (target) { var saveRequest = new Request.HTML({url: 'php/cheer.php'}).get( "name=" + $("NAME").get("value") + "&target=" + target ); Save(); Load(); } function ClearAiki () { var saveRequest = new Request.HTML({url: 'php/cheer.php'}).get( "name=" + $("NAME").get("value") + "&clear=1" ); Save(); Load(); } function UpdateKarma () { var karma = parseInt($("KARMA_MEIKYO").get("value")) + parseInt($("KARMA_PLAYER").get("value")); $("KARMA").set("value", karma); CheckForErrors(); } function UpdateMaxVit () { var vitality = parseInt($("SKILL_Body").get("value")) + parseInt($("SKILL_Spirit").get("value")); $("VITALITY_MAX").set("value", vitality); } function UpdateMaxSoul () { var soul = parseInt($("SKILL_Knowledge").get("value")) + parseInt($("SKILL_Spirit").get("value")); soul *= 2; $("SOUL_MAX").set("value", soul); } function UpdateTotalFateCost () { var total = 0; for (i = 0; i < 8; i++) { var num = parseInt(s_sliderValues["FATE_COST_" + i]); if (num == 3) total += 10; else if (num == 4) total += 30; else if (num == 5) total += 70; } $("FATE_COST_TOTAL").set("value", total); CheckForErrors(); } function UpdatesWounds () { var ligthWounds = parseInt($("SKILL_Body").get("value")); var heavyWounds = Math.ceil(ligthWounds / 2); var critWounds = Math.ceil(ligthWounds / 4); for (i = ligthWounds; i < 20; i++) { var elem = $("WOUND_LIGHT_" + i); elem.set('class', "block blockDisabled"); } for (i = heavyWounds; i < 10; i++) { var elem = $("WOUND_HEAVY_" + i); elem.set('class', "block blockDisabled"); } for (i = critWounds; i < 5; i++) { var elem = $("WOUND_CRIT_" + i); elem.set('class', "block blockDisabled"); } } function SetWounds (clickIndex, storeName, idName, maxCount) { woundIndex = 0; if (clickIndex == 0 && s_sliderValues[storeName] == 1) { // toggle var elem = $(idName + 0); if (elem.hasClass("blockChecked")) { elem.set('class', "block"); s_sliderValues[storeName] = 0; } else { elem.set('class', "block blockChecked"); s_sliderValues[storeName] = 1; } } else { for (; woundIndex <= clickIndex; ++woundIndex) { var elem = $(idName + woundIndex); if (elem.hasClass("blockDisabled")) break; elem.set('class', "block blockChecked"); } s_sliderValues[storeName] = woundIndex; } for (; woundIndex < maxCount; ++woundIndex) { var elem = $(idName + woundIndex); if (elem.hasClass("blockDisabled")) break; elem.set('class', "block"); } } function ClearWounds (storeName, idName, maxCount) { for (i = 0; i < maxCount; ++i) { var elem = $(idName + i); if (elem.hasClass("blockDisabled")) break; elem.set('class', "block"); } s_sliderValues[storeName] = 0; } function ClearDead () { var elem = $("WOUND_DEAD"); elem.set('class', "block"); s_sliderValues["dead"] = 0; } function SetDead () { var elem = $("WOUND_DEAD"); if (elem.hasClass("blockChecked")) { elem.set('class', "block"); s_sliderValues["dead"] = 0; } else { elem.set('class', "block blockChecked"); s_sliderValues["dead"] = 1; } } function CheckForErrors () { var karma = parseInt($("KARMA").get("value")); var fateKarma = parseInt($("FATE_COST_TOTAL").get("value")); if (karma >= fateKarma) $("FATE_COST_TOTAL").removeClass("error"); else $("FATE_COST_TOTAL").addClass("error"); if (karma <= 108) $("KARMA").removeClass("error"); else $("KARMA").addClass("error"); }