JavaScript is required. Please enable it to continue.
Your browser lacks required capabilities. Please upgrade it or switch to another to continue.
Loading…
,
,
,
,
,
,
,
,
,
,
<<for _i to 0; _i lt 10; _i++>> <<newWeapon>> <<set $weaponClone to clone(_weapon)>> ''@@color:yellow;<<print _i + 1 + '. '>>@@'' <<capture $weaponClone>> <<link "$weaponClone.name">> $inventory.pushUnique($weaponClone) <</link>> ''<<print ' (@@color:rgb(43,194,83);+' + $weaponClone.attack + '@@)'>> worth <<displayValue $weaponClone.value>>''<br> <</capture>> <</for>>
<<script>>setPageElement("splash", "Splash");<</script>> <<script>>setPageElement("startpage", "Startpage");<</script>> <<set $inventory to []>> <<set $debug to false>> <<if $debug>> <<removeclass "#footer" "remove">> <<else>> <<addclass "#footer" "remove">> <</if>> /* Currently in use */ <<set $lastAction to "Your last action is always displayed here." >> <<set $turn to 0>> /* ------------------------- */ /* XP-table for level checks */ <<set setup.xpTable to [ NaN, /* Level 0 */ 0, /* Level 1 */ 300, /* Level 2 */ 900, /* Level 3 */ 2700, /* Level 4 */ 6500, /* Level 5 */ 14000, /* Level 6 */ 23000, /* Level 7 */ 34000, /* Level 8 */ 48000, /* Level 9 */ 64000, /* Level 10 */ 85000, /* Level 11 */ 100000, /* Level 12 */ 120000, /* Level 13 */ 140000, /* Level 14 */ 165000, /* Level 15 */ 195000, /* Level 16 */ 225000, /* Level 17 */ 265000, /* Level 18 */ 305000, /* Level 19 */ 355000 /* Level 20 */ ]>> <<set $player to { currency : 0 }>> <<set $player1 to { name : "Brother", level : 1, xp : 0, thisLevelXP : 0, nextLevelXP : 300, hp : 100, hpMax : 100, mp : 10, mpMax : 10, attack : 10, crit : 5, defense : 0, melee : 0, ranged : 0, spell : 0, thisDamage : 0, totalDamage : 0, weapon : { id : "w" + (new Date().getTime() + Math.random() * 0x10000000000).toString(16), itemType: "weapon", property: ['bludgeoning', 'one-handed'], name : 'common stick', attack : 10, type : 'melee' }, armor : { id : "a" + (new Date().getTime() + Math.random() * 0x10000000000).toString(16), itemType: "armor", name : 'cloth tunic', defense : 10, type : 'chest' } }>> <<set $player1.thisLevelXP to $player.xp - setup.xpTable[$player.level]>> <<set $player1.nextLevelXP to setup.xpTable[$player.level +1] - setup.xpTable[$player.level]>> <<set $player2 to { name : "Sister", level : 1, xp : 0, thisLevelXP : 0, nextLevelXP : 300, hp : 100, hpMax : 100, mp : 10, mpMax : 10, attack : 10, crit : 5, defense : 0, melee : 0, ranged : 0, spell : 0, thisDamage : 0, totalDamage : 0, weapon : { id : "w" + (new Date().getTime() + Math.random() * 0x10000000000).toString(16), itemType: "weapon", property: ['bludgeoning', 'one-handed'], name : 'common stick', attack : 10, type : 'melee' }, armor : { id : "a" + (new Date().getTime() + Math.random() * 0x10000000000).toString(16), itemType: "armor", name : 'cloth tunic', defense : 10, type : 'chest' } }>> <<set $player2.thisLevelXP to $player.xp - setup.xpTable[$player.level]>> <<set $player2.nextLevelXP to setup.xpTable[$player.level +1] - setup.xpTable[$player.level]>> <<set $enemyArray to [ { name : "mink", attack : 4, hp : 25, hpMax : 25 }, { name : "fox", attack : 6, hp : 50, hpMax : 50 }, { name : "wolf", attack : 8, hp : 75, hpMax : 75 }, { name : "bear", attack : 12, hp : 100, hpMax : 100 }, { name : "warthog", attack : 10, hp : 75, hpMax : 75 }, { name : "moose", attack : 12, hp : 100, hpMax : 100 }, { name : "lynx", attack : 10, hp : 75, hpMax : 75 }, { name : "badger", attack : 12, hp : 100, hpMax : 100 }, { name : "red dragon", attack : 50, hp : 500, hpMax : 500 } ]>> <<set $enemy to $enemyArray.random()>> <<set $enemy.hpMax to $enemy.hp>> /* ----------- */ /* Loot-tables */ <<set setup.itemRarity to [ { name: 'common', multiplier: 1.0, weight: 40 }, { name: 'rare', multiplier: 1.25, weight: 20 }, { name: 'epic', multiplier: 1.50, weight: 5 }, { name: 'legendary', multiplier: 1.75, weight: 1 } ]>> <<set setup.itemRarityWeightSum to setup.utils.sumWeights(setup.itemRarity)>> <<set setup.itemPrefix to [ { name: "warrior's", min: 2, max: 4 }, { name: "soldier's", min: 6, max: 8 }, { name: "knight's", min: 10, max: 12 }, { name: "lord's", min: 14, max: 16 }, { name: "king's", min: 18, max: 20 }, { name: "master's", min: 22, max: 24 }, { name: "grandmaster's", min: 26, max: 28 } ]>> <<set setup.itemWeapon to [ /* MELEE WEAPONS */ { name: 'battleaxe', type: 'melee', property: ['slashing', 'one-handed'], attack: 6, value: 100 }, { name: 'club', type: 'melee', property: ['bludgeoning', 'one-handed'], attack: 4, value: 1 }, { name: 'dagger', type: 'melee', property: ['piercing', 'one-handed'], attack: 4, value: 20 }, { name: 'flail', type: 'melee', property: ['bludgeoning', 'one-handed'], attack: 8, value: 100 }, { name: 'glaive', type: 'melee', property: ['slashing', 'two-handed'], attack: 10, value: 200 }, { name: 'greataxe', type: 'melee', property: ['slashing', 'two-handed'], attack: 12, value: 300 }, { name: 'greatclub', type: 'melee', property: ['bludgeoning', 'two-handed'], attack: 8, value: 2 }, { name: 'greatsword', type: 'melee', property: ['slashing', 'two-handed'], attack: 12, value: 500 }, { name: 'halberd', type: 'melee', property: ['slashing', 'two-handed'], attack: 10, value: 200 }, { name: 'handaxe', type: 'melee', property: ['slashing', 'one-handed'], attack: 6, value: 50 }, { name: 'javelin', type: 'melee', property: ['piercing', 'one-handed'], attack: 6, value: 5 }, { name: 'light hammer', type: 'melee', property: ['bludgeoning', 'one-handed'], attack: 4, value: 20 }, { name: 'longsword', type: 'melee', property: ['slashing', 'one-handed'], attack: 8, value: 150 }, { name: 'mace', type: 'melee', property: ['bludgeoning', 'one-handed'], attack: 6, value: 50 }, { name: 'maul', type: 'melee', property: ['bludgeoning', 'two-handed'], attack: 12, value: 100 }, { name: 'morningstar', type: 'melee', property: ['piercing', 'one-handed'], attack: 8, value: 150 }, { name: 'pike', type: 'melee', property: ['piercing', 'two-handed'], attack: 10, value: 50 }, { name: 'quarterstaff', type: 'melee', property: ['bludgeoning', 'one-handed'], attack: 6, value: 2 }, { name: 'rapier', type: 'melee', property: ['piercing', 'one-handed'], attack: 8, value: 250 }, { name: 'scimitar', type: 'melee', property: ['slashing', 'one-handed'], attack: 6, value: 250 }, { name: 'shortsword', type: 'melee', property: ['piercing', 'one-handed'], attack: 6, value: 100 }, { name: 'sickle', type: 'melee', property: ['slashing', 'one-handed'], attack: 4, value: 10 }, { name: 'spear', type: 'melee', property: ['piercing', 'one-handed'], attack: 6, value: 10 }, { name: 'trident', type: 'melee', property: ['piercing', 'one-handed'], attack: 6, value: 50 }, { name: 'war pick', type: 'melee', property: ['piercing', 'one-handed'], attack: 8, value: 50 }, { name: 'warhammer', type: 'melee', property: ['bludgeoning', 'one-handed'], attack: 8, value: 150 }, { name: 'whip', type: 'melee', property: ['slashing', 'one-handed'], attack: 4, value: 20 }, /* RANGED WEAPONS */ { name: 'hand crossbow', type: 'ranged', property: ['piercing', 'one-handed'], attack: 6, value: 750 }, { name: 'heavy crossbow', type: 'ranged', property: ['piercing', 'two-handed'], attack: 10, value: 500 }, { name: 'light crossbow', type: 'ranged', property: ['piercing', 'two-handed'], attack: 8, value: 250 }, { name: 'longbow', type: 'ranged', property: ['piercing', 'two-handed'], attack: 8, value: 500 }, { name: 'shortbow', type: 'ranged', property: ['piercing', 'two-handed'], attack: 6, value: 250 }, { name: 'sling', type: 'ranged', property: ['bludgeoning', 'one-handed'], attack: 4, value: 1 } ]>> <<set setup.itemSuffix to [ { name: "", attack: 0, crit: 0 }, { name: "of pain", attack: 0, crit: 5 }, { name: "of agony", attack: 5, crit: 15 }, { name: "of power", attack: 2, crit: 0 } ]>> <<set setup.itemArmor to [ { name: 'leather armor', type: 'chest', defense: 11, value: 100 }, { name: 'padded armor', type: 'chest', defense: 11, value: 50 }, { name: 'studded leather armor', type: 'chest', defense: 12, value: 450 }, { name: 'breastplate', type: 'chest', defense: 14, value: 4000 }, { name: 'chain shirt', type: 'chest', defense: 13, value: 500 }, { name: 'half plate', type: 'chest', defense: 15, value: 7500 }, { name: 'hide armor', type: 'chest', defense: 12, value: 100 }, { name: 'scale mail', type: 'chest', defense: 14, value: 500 }, { name: 'chain mail', type: 'chest', defense: 16, value: 750 }, { name: 'plate armor', type: 'chest', defense: 18, value: 15000 }, { name: 'ring mail', type: 'chest', defense: 14, value: 300 }, { name: 'splint armor', type: 'chest', defense: 17, value: 2000 }, ]>> <<set setup.deck to [ { card: "ace", suit: "hearts", value: 1 }, { card: "two", suit: "hearts", value: 2 }, { card: "three", suit: "hearts", value: 3 }, { card: "four", suit: "hearts", value: 4 }, { card: "five", suit: "hearts", value: 5 }, { card: "six", suit: "hearts", value: 6 }, { card: "seven", suit: "hearts", value: 7 }, { card: "eight", suit: "hearts", value: 8 }, { card: "nine", suit: "hearts", value: 9 }, { card: "ten", suit: "hearts", value: 10 }, { card: "knight", suit: "hearts", value: 11 }, { card: "queen", suit: "hearts", value: 12 }, { card: "king", suit: "hearts", value: 13 }, { card: "ace", suit: "clubs", value: 1 }, { card: "two", suit: "clubs", value: 2 }, { card: "three", suit: "clubs", value: 3 }, { card: "four", suit: "clubs", value: 4 }, { card: "five", suit: "clubs", value: 5 }, { card: "six", suit: "clubs", value: 6 }, { card: "seven", suit: "clubs", value: 7 }, { card: "eight", suit: "clubs", value: 8 }, { card: "nine", suit: "clubs", value: 9 }, { card: "ten", suit: "clubs", value: 10 }, { card: "knight", suit: "clubs", value: 11 }, { card: "queen", suit: "clubs", value: 12 }, { card: "king", suit: "clubs", value: 13 }, { card: "ace", suit: "diamonds", value: 1 }, { card: "two", suit: "diamonds", value: 2 }, { card: "three", suit: "diamonds", value: 3 }, { card: "four", suit: "diamonds", value: 4 }, { card: "five", suit: "diamonds", value: 5 }, { card: "six", suit: "diamonds", value: 6 }, { card: "seven", suit: "diamonds", value: 7 }, { card: "eight", suit: "diamonds", value: 8 }, { card: "nine", suit: "diamonds", value: 9 }, { card: "ten", suit: "diamonds", value: 10 }, { card: "knight", suit: "diamonds", value: 11 }, { card: "queen", suit: "diamonds", value: 12 }, { card: "king", suit: "diamonds", value: 13 }, { card: "ace", suit: "spades", value: 1 }, { card: "two", suit: "spades", value: 2 }, { card: "three", suit: "spades", value: 3 }, { card: "four", suit: "spades", value: 4 }, { card: "five", suit: "spades", value: 5 }, { card: "six", suit: "spades", value: 6 }, { card: "seven", suit: "spades", value: 7 }, { card: "eight", suit: "spades", value: 8 }, { card: "nine", suit: "spades", value: 9 }, { card: "ten", suit: "spades", value: 10 }, { card: "knight", suit: "spades", value: 11 }, { card: "queen", suit: "spades", value: 12 }, { card: "king", suit: "spades", value: 13 } ]>>
<<widget 'X'>> <span style="float: right; border: 1px solid black; min-width: 25px;"><<link "X">><<run setup.popup.close()>><</link>></span> <</widget>>
<<set $moveBtn to false>> <<set $turn to 0>> <<set $enemyPresent to true>> <<set $player1.thisDamage to 0>> <<set $player2.thisDamage to 0>> <<enemyHP>> <div id="output" style="overflow-y: scroll; height: 35vh; max-height: 35vh; min-width: 50%; border: 2px solid darkorange; padding: 5px"></div>
<<set $moveBtn to true>> This is the tale of two siblings, $player1.name and $player2.name.<br> <br> Their journey begins here.<br> <br> <br> <hr> DEBUG LOCATIONS:<br> [[locationCamp]]<br> [[locationTavernOutside]]<br> [[locationForest]]<br>
<div style="display: flex; justify-content: center"> <div style="height: 100%; padding: 3px 5px 5px 5px"> <div style="float: left; margin-right: 5px"> <<player $player1>> <<playerXP $player1>> <<playerHP $player1>> <<playerMP $player1>> </div> <div style="float: left; margin-right: 5px"> <center> <<button "☰">> <<popup 'popOptions'>> <</button>> <br> <<button "INV">> <<set _tab to "weapons">> <<popup 'popInventory'>> <</button>> </center> </div> <div style="float: left"> <<player $player2>> <<playerXP $player2>> <<playerHP $player2>> <<playerMP $player2>> </div> </div> </div> <center><<playerCurrency>></center>
<popTop>Options<<X>></popTop> <center> <<button "RESTART">><<script>>Engine.restart();<</script>><</button>> </center>
<div id="splash"></div> <div id="startpage"></div> <div id="interface" class="wrapper"> <div id="header" data-passage="Header" class="header"></div> <div id="passages" class="main"></div> <div class="bottom"> <div id="actionbar" data-passage="ActionBar" class="actionbar"></div> <div id="footer" data-passage="Footer" class="footer"></div> </div> </div>
<center> <table> <tr> <td> [[fightEnemy]] | [[debugWeapon]] | [[debugArmor]] | [[debugCurrency]] | [[debugDamage]] </td> </tr> </table> Copyright © Tomas Jelf Werner </center> <<updateStats $player1>> <<updateStats $player2>>
<<for _i to 0; _i lt 10; _i++>> <<newArmor>> ''@@color:yellow;<<print _i + 1 + '. '>>@@'' ''<<print $armor.name + ' (@@color:rgb(43,194,83);+' + $armor.defense + '@@)'>> worth <<displayValue $armor.value>>''<br> <</for>>
/* WORKS ----- Resting both siblings at once Turn-based combat Moving on to random locations work Basic inventory Finding weapons Replacing weapons DOESN'T WORK ------------ 2p Spellcasting Advanced inventory Finding armor Replacing armor <span id="displayWeapon"> You found a <b>_weapon.name <<if $player1.weapon.attack == _weapon.attack>> (@@color:white;+0@@) <<elseif $player1.weapon.attack <= _weapon.attack>> (@@color:rgb(43,194,83);+<<= _weapon.attack-$player1.weapon.attack>>@@) <<elseif $player1.weapon.attack >= _weapon.attack>> (@@color:red;-<<= $player1.weapon.attack-$_weapon.attack>>@@) <</if>> </b> </span> RANDOM NOTES ------------ Fire beats Earth Earth beats Air Air beats Water Water beats Fire Church - Farmers? - Nobility <<set $list to Story.lookup("tags", "spell")>> <<for $i to 0; $i lt $list.length; ++$i>> <<print "[" + "[" + $list[$i].title + "]" + "]">> <</for>> <<unset $list, $i>> */
<popTop>GAME OVER</popTop> Unfortunately your journey ends here. <br> <br> <center> <<button "RESTART">><<script>>Engine.restart();<</script>><</button>> </center>
<div id="actionBar" style="min-width: 100%"> <<if $rewardBtn>> <<button "REWARDS">> <<lastAction "You found something.">> <<goto "fightRewards">> <</button>> <<elseif tags().includes("turnCombat") and $enemyPresent>> <span id="playerActions"> <<button "$player1.name">> <<replace "#playerActions">> <<button "Melee attack">> <<lastAction "$player1.name attacked.">> <<turnCombat $player1>> <</button>> <<if tags().includes("spell")>> <<button "Cast Spell">> <<lastAction "You considered casting a spell.">> <<popup 'popSpell' $player1>> <</button>> <</if>> <</replace>> <</button>> <<button "$player2.name">> <<replace "#playerActions">> <<button "Melee attack">> <<lastAction "$player2.name attacked.">> <<turnCombat $player2>> <</button>> <<if tags().includes("spell")>> <<button "Cast Spell">> <<lastAction "You considered casting a spell.">> <<popup 'popSpell' $player2>> <</button>> <</if>> <</replace>> <</button>> </span> <<else>> <<if tags().includes("attack") and $enemyPresent>> <<button "Attack">> <<lastAction "You decided to attack.">> <<goto "fightEnemy">> <</button>> <</if>> <<if tags().includes("replace")>> <span id="replaceItemBtn"> <<if _addItem is "weapon">> <<button "Pick up weapon">> <<run $inventory.push(clone(_weapon))>> <<toggleclass "#replaceItemBtn" "remove">> <<set _addItem to "none">> <<replace "#displayItem">><</replace>> <</button>> <</if>> <<if _addItem is "armor">> <<button "Pick up armor">> <<run $inventory.push(clone(_armor))>> <<toggleclass "#replaceItemBtn" "remove">> <<set _addItem to "none">> <<replace "#displayItem">><</replace>> <</button>> <</if>> </span> <</if>> <<if tags().includes("inventory")>> <span id="inventoryBtn"> <<button "Inventory">> <<lastAction "You browsed your inventory.">> <<popup 'popInventory'>> <</button>> </span> <</if>> <<if tags().includes("move")>> <span id="moveBtn"> <<button "Keep Walking">> <<lastAction "You kept on walking.">> <<keepWalking>> <</button>> </span> <</if>> <<if tags().includes("enter")>> <span id="moveBtn"> <<button "Enter">> <<lastAction "You went inside.">> <<goto "locationTavernInside">> <</button>> </span> <</if>> <<if tags().includes("exit")>> <span id="moveBtn"> <<button "Leave">> <<lastAction "You went outside.">> <<goto "locationTavernOutside">> <</button>> </span> <</if>> <<if tags().includes("dice")>> <span id="moveBtn"> <<button "Play dice">> <<lastAction "You decided to play some dice.">> <<popup 'popDice'>> <</button>> </span> <</if>> <<if tags().includes("cards21")>> <span id="moveBtn"> <<button "Play cards">> <<lastAction "You decided to play some cards.">> <<popup 'popCards21'>> <</button>> </span> <</if>> <<if tags().includes("rest")>> <span id="restBtn"> <<button "Rest">> <<lastAction "You decided to rest.">> <<popup 'popRest'>> <</button>> </span> <</if>> <</if>> </div> <div style="min-width: 100%; padding-top: 10px;"> <span id="displayAction">$lastAction</span> </div>
<popTop>LEVEL UP<<X>></popTop> ''You have reached level $player1.level.''<br> <br> Your total health points increased! (''@@color:#f42323;+10 HP@@'')<br> Your total magic points increased! (''@@color:#007bff;+5 MP@@'')
<div id="inventory"> <popTop>INVENTORY<<X>></popTop> <popTab> <<if _tab is "weapons">> <span id="weapons" class="activeTab"> <<link "Weapons">><<addclass "#weapons" "activeTab">><<removeclass "#armor" "activeTab">><<removeclass "#items" "activeTab">><<replace "#contents">><<backpack "weapons">><</replace>><</link>> </span> <<else>> <span id="weapons"> <<link "Weapons">><<addclass "#weapons" "activeTab">><<removeclass "#armor" "activeTab">><<removeclass "#items" "activeTab">><<replace "#contents">><<backpack "weapons">><</replace>><</link>> </span> <</if>> <<if _tab is "armor">> <span id="armor" class="activeTab"> <<link "Armor">><<addclass "#armor" "activeTab">><<removeclass "#weapons" "activeTab">><<removeclass "#items" "activeTab">><<replace "#contents">><<backpack "armor">><</replace>><</link>> </span> <<else>> <span id="armor"> <<link "Armor">><<addclass "#armor" "activeTab">><<removeclass "#weapons" "activeTab">><<removeclass "#items" "activeTab">><<replace "#contents">><<backpack "armor">><</replace>><</link>> </span> <</if>> <<if _tab is "items">> <span id="items" class="activeTab"> <<link "Items">><<addclass "#items" "activeTab">><<removeclass "#armor" "activeTab">><<removeclass "#weapons" "activeTab">><<replace "#contents">><<backpack "items">><</replace>><</link>> </span> <<else>> <span id="items"> <<link "Items">><<addclass "#items" "activeTab">><<removeclass "#armor" "activeTab">><<removeclass "#weapons" "activeTab">><<replace "#contents">><<backpack "items">><</replace>><</link>> </span> <</if>> </popTab> <div id="contents"> <<if _tab is "weapons">> <<backpack "weapons">> <<elseif _tab is "armor">> <<backpack "armor">> <<elseif _tab is "items">> <<backpack "items">> <</if>> </div> <br> <br> <table style = "width: 100%"> <caption>''You are currently using<br><br>''</caption> <tr> <th>$player1.name's weapon: </th> <td> <<if $player1.weapon.name>>$player1.weapon.name ($player1.weapon.attack attack) <<else>>Nothing <</if>> </td> </tr> <tr> <th>$player1.name's armor: </th> <td> <<if $player1.armor.name>>$player1.armor.name ($player1.armor.defense defense) <<else>>Nothing <</if>> </td> </tr> <tr> <th>$player2.name's weapon: </th> <td> <<if $player2.weapon.name>>$player2.weapon.name ($player2.weapon.attack attack) <<else>>Nothing <</if>> </td> </tr> <tr> <th>$player2.name's armor: </th> <td> <<if $player2.armor.name>>$player2.armor.name ($player2.armor.defense defense) <<else>>Nothing <</if>> </td> </tr> </table> </div>
<<for _i to 0; _i lt 10; _i++>> <<newWeapon>> ''@@color:yellow;<<print _i + 1 + '. '>>@@'' ''You have received <<addCurrency 1 100>>!''<br> <</for>>
<<for _i to 0; _i lt 10; _i++>> <<set $enemyAttack to 100>> <<set _damageToPlayer to Math.max(1, Math.trunc($enemyAttack*(100/(100+$player.defense))))>> <<set $player.hp -= _damageToPlayer>> <<set $player.defense += random(5,25)>> <<updateStats>> ''@@color:yellow;<<print _i + 1 + '. '>>@@'' ''You have received _damageToPlayer damage at $player.defense DEFENSE!''<br> <</for>>
<popTop>_player.name's Spells<<X>></popTop> <popTab> <span id="tier1" class="activeTab"> <<link "Tier 1">><<addclass "#tier1" "activeTab">><<removeclass "#tier2" "activeTab">><<removeclass "#tier3" "activeTab">><<replace "#contents">><<spellBook _player "tier1">><</replace>><</link>> </span> <span id="tier2"> <<link "Tier 2">><<addclass "#tier2" "activeTab">><<removeclass "#tier1" "activeTab">><<removeclass "#tier3" "activeTab">><<replace "#contents">><<spellBook _player "tier2">><</replace>><</link>> </span> <span id="tier3"> <<link "Tier 3">><<addclass "#tier3" "activeTab">><<removeclass "#tier2" "activeTab">><<removeclass "#tier1" "activeTab">><<replace "#contents">><<spellBook _player "tier3">><</replace>><</link>> </span> </popTab> <div id="contents"> <<spellBook _player "tier1">> </div>
/* ------------------------------------------------------------------- */ /* Checks for enough MP to cast a given spell and then casts it */ /* Usage: <<castSpell $player1 "minor healing">> in <link> or <button> */ <<widget "castSpell">> /* SWITCH MACRO EXECUTES THE PROPER SPELL */ /* -------------------------------------- */ <<set _player = $args[0]>> <<switch $args[1]>> /* ----------------------------- TIER 1 ------------------------------ */ <<case "minor healing">> <<if _player.mp lt 10>> <<replace #displayAction>> You don't have enough magic points!<</replace>> <<else>> <<set _player.spell++>> <<set _player.mp = Math.clamp(_player.mp - 10, 0, _player.mpMax)>> <<set _player.hp = Math.clamp(_player.hp + 20, 0, _player.hpMax)>> <<replace #displayAction>> You spend @@.blue;-10 MP@@ casting MINOR HEALING. You are healed @@.red;+20 HP@@.<</replace>> <</if>> <<case "firebolt">> <<if _player.mp lt 10>> <<replace #displayAction>> You don't have enough magic points!<</replace>> <<else>> <<set _player.spell++>> <<set $castSpell to "firebolt">> <<set _player.mp = Math.clamp(_player.mp - 10, 0, _player.mpMax)>> <<replace #displayAction>> You spend @@.blue;-10 MP@@ casting FIREBOLT against your enemy.<</replace>> <<turnCombat _player>> <</if>> /* ----------------------------- TIER 2 ------------------------------ */ <<case "healing">> <<if _player.mp lt 15>> <<replace #displayAction>> You don't have enough magic points!<</replace>> <<else>> <<set _player.spell++>> <<set _player.mp = Math.clamp(_player.mp - 15, 0, _player.mpMax)>> <<set _player.hp = Math.clamp(_player.hp + 40, 0, _player.hpMax)>> <<replace #displayAction>> You spend @@.blue;-15 MP@@ casting HEALING. You are healed @@.red;+40 HP@@.<</replace>> <</if>> /* ----------------------------- TIER 3 ------------------------------ */ <<case "major healing">> <<if _player.mp lt 20>> <<replace #displayAction>> You don't have enough magic points!<</replace>> <<else>> <<set _player.spell++>> <<set _player.mp = Math.clamp(_player.mp - 20, 0, _player.mpMax)>> <<set _player.hp = Math.clamp(_player.hp + 80, 0, _player.hpMax)>> <<replace #displayAction>> You spend @@.blue;-20 MP@@ casting MAJOR HEALING. You are healed @@.red;+80 HP@@.<</replace>> <</if>> /* ----------------------------- FAILED ------------------------------ */ <<default>> <<replace #displayAction>>Your spell fizzles and dies.<</replace>> <</switch>> <<updateStats $player1>> <<updateStats $player2>> <</widget>>
You come across an abandoned camp site. The fire is out, but the coal is still warm.<br> <br> If you wanted to, you could propably rest here for awhile.
<<set _popupRest to true>> <popTop>RESTING</popTop> <center> <h3>You lie down by the camp fire to get some rest.</h3> @@#healthpop;@@<br> <br> <<silently>> <<repeat 1s>> <<if _popupRest>> <<if $player1.hp is $player1.hpMax and $player2.hp is $player2.hpMax and $player1.mp is $player1.mpMax and $player2.mp is $player2.mpMax>> <<replace "#healthpop">> <b>You are both fully rested!</b> <</replace>> <<stop>> <</if>> <<set $player1.hp to Math.trunc(Math.clamp($player1.hp + ($player1.hpMax/10), 0, $player1.hpMax))>> <<set $player2.hp to Math.trunc(Math.clamp($player2.hp + ($player2.hpMax/10), 0, $player2.hpMax))>> <<set $player1.mp to Math.trunc(Math.clamp($player1.mp + ($player1.mpMax/10), 0, $player1.mpMax))>> <<set $player2.mp to Math.trunc(Math.clamp($player2.mp + ($player2.mpMax/10), 0, $player2.mpMax))>> <<replace "#healthpop">> <b>You both get some rest...</b> <</replace>> <<updateStats $player1>> <<updateStats $player2>> <<else>> <<stop>> <</if>> <</repeat>> <</silently>> <<button "CONTINUE">> <<set _popupRest to false>> <<run setup.popup.close()>> <</button>> </center>
/* ----------------------------------------------------------------- */ /* Generates a piece of armor from an array of prefixes and names. */ <<widget 'newArmor'>> /* generate armor piece randomly */ <<set _rarity to setup.utils.weightedRandom(setup.itemRarity, setup.itemRarityWeightSum)>> <<set _armor to setup.itemArmor.random()>> <<if _rarity.name eq 'common'>> <<set _prefix to setup.itemPrefix[random(0, 1)]>> <<set _str = '@@color:white;' + _prefix.name + ' ' + _armor.name + '@@'>> <<elseif _rarity.name eq 'rare'>> <<set _prefix to setup.itemPrefix[random(2, 3)]>> <<set _str = '@@color:deepskyblue;' + _prefix.name + ' ' + _armor.name + '@@'>> <<elseif _rarity.name eq 'epic'>> <<set _prefix to setup.itemPrefix[random(4, 5)]>> <<set _str = '@@color:fuchsia;' + _prefix.name + ' ' + _armor.name + '@@'>> <<elseif _rarity.name eq 'legendary'>> <<set _prefix to setup.itemPrefix[6]>> <<set _str = '@@color:orange;' + _prefix.name + ' ' + _armor.name + '@@'>> <</if>> /* build armor */ <<set _armor to { id : "a" + (new Date().getTime() + Math.random() * 0x10000000000).toString(16), itemType: "armor", name : _str, defense : _armor.defense + Math.trunc(_rarity.multiplier * random(_prefix.min, _prefix.max)), type : _armor.type, value : Math.trunc(_rarity.multiplier * _armor.value) }>> <</widget>>
/* ----------------------------------------------------------------- */ /* Generates a weapon from an array of prefixes, names and suffixes. */ <<widget 'newWeapon'>> /* generate weapon randomly */ <<set _rarity to setup.utils.weightedRandom(setup.itemRarity, setup.itemRarityWeightSum)>> <<set _weapon to setup.itemWeapon.random()>> <<if _rarity.name eq 'common'>> <<set _prefix to setup.itemPrefix[random(0, 1)]>> <<set _suffix to setup.itemSuffix[0]>> <<set _str = '@@color:white;' + _prefix.name + ' ' + _weapon.name + '@@'>> <<elseif _rarity.name eq 'rare'>> <<set _prefix to setup.itemPrefix[random(2, 3)]>> <<set _suffix to setup.itemSuffix[0]>> <<set _str = '@@color:deepskyblue;' + _prefix.name + ' ' + _weapon.name + '@@'>> <<elseif _rarity.name eq 'epic'>> <<set _prefix to setup.itemPrefix[random(4, 5)]>> <<set _suffix to setup.itemSuffix[random(1, 2)]>> <<set _str = '@@color:fuchsia;' + _prefix.name + ' ' + _weapon.name + ' ' + _suffix.name + '@@'>> <<elseif _rarity.name eq 'legendary'>> <<set _prefix to setup.itemPrefix[6]>> <<set _suffix to setup.itemSuffix[random(1, 2)]>> <<set _str = '@@color:orange;' + _prefix.name + ' ' + _weapon.name + ' ' + _suffix.name + '@@'>> <</if>> /* build weapon */ <<set _weapon to { id : "w" + (new Date().getTime() + Math.random() * 0x10000000000).toString(16), itemType: "weapon", property: _weapon.property, name : _str, attack : _weapon.attack + Math.trunc(_rarity.multiplier * random(_prefix.min, _prefix.max)) + _suffix.attack, crit : _suffix.crit, type : _weapon.type, value : Math.trunc(_rarity.multiplier * _weapon.value) }>> <</widget>>
/* ------------------------------------------------------------------- */ /* Generates a random amount of Currency to add to the Player's */ /* Usage: <<addCurrency 10 100>> randomizes the Min and Max added */ <<widget 'addCurrency'>> <<set _addCurrency to random($args[0], $args[1])>> <<set _addGold to Math.trunc((_addCurrency/100))>> <<set _addSilver to Math.trunc(_addCurrency%100)>> <<set $player.currency += _addCurrency>> <<if _addGold gt 0 and _addSilver gt 0>> ?addGold and ?addSilver\ <<elseif _addGold gt 0>> ?addGold\ <<elseif _addSilver gt 0>> ?addSilver<</if>>\ <</widget>> <<widget 'displayValue'>> <<set _value to $args>> <<set _addGold to Math.trunc((_value/100))>> <<set _addSilver to Math.trunc(_value%100)>> <<if _addGold gt 0 and _addSilver gt 0>> ?addGold and ?addSilver\ <<elseif _addGold gt 0>> ?addGold\ <<elseif _addSilver gt 0>> ?addSilver<</if>>\ <</widget>>
/* ------------------------------------------------------------------- */ /* Moves the player ahead one passage and displays the decision. */ <<widget 'keepWalking'>> <<set $actionLast to "You keep walking!" >><<replace #displayAction>>$actionLast<</replace>> <<goto `either("locationCamp", "locationTavernOutside","locationForest", "locationForest", "locationForest")`>> <</widget>>
/* ----------------------------------------------------------------- */ /* Replaces the current weapon with a new one and displays the action. */ <<widget 'replaceWeapon'>> <<set _player = $args[0]>> <<set _id = $args[1]>> <<set _obj = $inventory.find(function(o) { return o && o.id === _id; })>> <<if _player && _id && _obj>> <<set $actionLast to "You swap your ''_player.weapon.name'' for a ''_obj.name''!" >> <<replace #displayAction>>$actionLast<</replace>> <<set $previousWeapon to _player.weapon>> <<set _player.weapon to _obj>> <<run $inventory.delete(_obj)>> <<run $inventory.push($previousWeapon)>> <</if>> <</widget>>
/* ----------------------------------------------------------------- */ /* Replaces the current armor with a new one and displays the action. */ <<widget 'replaceArmor'>> <<set _player = $args[0]>> <<set _id = $args[1]>> <<set _obj = $inventory.find(function(o) { return o && o.id === _id; })>> <<if _player && _id && _obj>> <<set $actionLast to "You swap your ''_player.armor.name'' for a ''_obj.name''!" >> <<replace #displayAction>>$actionLast<</replace>> <<set $previousArmor to _player.armor>> <<set _player.armor to _obj>> <<run $inventory.delete(_obj)>> <<run $inventory.push($previousArmor)>> <</if>> <</widget>>
/* ----------------------------------------------------------------- */ /* Updates level, experience, and similar statistics */ <<widget 'updateStats'>> <<set _player = $args[0]>> <<if _player is $player1>> /* Check for level up. */ <<if $player1.level < (setup.xpTable.length - 1) and $player1.xp >= setup.xpTable[$player1.level + 1]>> /* Find the greatest level the player has earned. */ <<set _toLevel to setup.xpTable.findIndex(function (req) { return $player1.xp < req; }) - 1>> <<if _toLevel is -2>> /* Correct for max level. */ <<set _toLevel to setup.xpTable.length - 1>> <</if>> /* How many levels were gained. */ <<set _gained to _toLevel - $player1.level>> /* Assign their new level. */ <<set $player1.level to _toLevel>> <<set $player1.hpMax += 10>> <<set $player1.mpMax += 5>> <<set $player1.hp to $player1.hpMax>> <<set $player1.mp to $player1.mpMax>> <<popup 'popLevelUp'>> /* Whatever else you need to do with _gained or $playerLevel. */ <</if>> <<set $player1.thisLevelXP to $player1.xp - setup.xpTable[$player1.level]>> <<set $player1.nextLevelXP to setup.xpTable[$player1.level +1] - setup.xpTable[$player1.level]>> /* Updates visible stats in the header */ <<replace #player1LEVEL>>Lvl.$player1.level<</replace>> <<replace #player1XP>>$player1.thisLevelXP / $player1.nextLevelXP XP<</replace>> <<replace #player1HP>>$player1.hp / $player1.hpMax HP<</replace>> <<replace #player1MP>>$player1.mp / $player1.mpMax MP<</replace>> /* UPDATES THE VISIBLE HEALTH BARS BY RUNNING JAVASCRIPT FUNCTIONS */ /* --------------------------------------------------------------- */ <<run ProgressBar.updateBar('#player1-experience', $player1.nextLevelXP, $player1.thisLevelXP)>> <<run ProgressBar.updateBar('#player1-health', $player1.hpMax, $player1.hp)>> <<run ProgressBar.updateBar('#player1-magic', $player1.mpMax, $player1.mp)>> <<else>> /* Check for level up. */ <<if $player2.level < (setup.xpTable.length - 1) and $player2.xp >= setup.xpTable[$player2.level + 1]>> /* Find the greatest level the player has earned. */ <<set _toLevel to setup.xpTable.findIndex(function (req) { return $player2.xp < req; }) - 1>> <<if _toLevel is -2>> /* Correct for max level. */ <<set _toLevel to setup.xpTable.length - 1>> <</if>> /* How many levels were gained. */ <<set _gained to _toLevel - $player2.level>> /* Assign their new level. */ <<set $player2.level to _toLevel>> <<set $player2.hpMax += 10>> <<set $player2.mpMax += 5>> <<set $player2.hp to $player2.hpMax>> <<set $player2.mp to $player2.mpMax>> <<popup 'popLevelUp'>> /* Whatever else you need to do with _gained or $playerLevel. */ <</if>> <<set $player2.thisLevelXP to $player2.xp - setup.xpTable[$player2.level]>> <<set $player2.nextLevelXP to setup.xpTable[$player2.level +1] - setup.xpTable[$player2.level]>> /* Updates visible stats in the header */ <<replace #player2LEVEL>>Lvl.$player2.level<</replace>> <<replace #player2XP>>$player2.thisLevelXP / $player2.nextLevelXP XP<</replace>> <<replace #player2HP>>$player2.hp / $player2.hpMax HP<</replace>> <<replace #player2MP>>$player2.mp / $player2.mpMax MP<</replace>> /* UPDATES THE VISIBLE HEALTH BARS BY RUNNING JAVASCRIPT FUNCTIONS */ /* --------------------------------------------------------------- */ <<run ProgressBar.updateBar('#player2-experience', $player2.nextLevelXP, $player2.thisLevelXP)>> <<run ProgressBar.updateBar('#player2-health', $player2.hpMax, $player2.hp)>> <<run ProgressBar.updateBar('#player2-magic', $player2.mpMax, $player2.mp)>> <</if>> <</widget>>
/* DISPLAYS PLAYABLE CHARACTERS' NAME AND LEVEL */ /* -------------------------------------------------- */ <<widget 'player'>> <<set _player = $args[0]>> <<if _player is $player1>> <div class="player-bar"> ''@@color:orange;padding-left:10px;float:left;$player1.name@@@@#player1LEVEL;color:orange;padding-right:2px;float:right;Lvl.$player1.level@@'' </div> <<else>> <div class="player-bar"> ''@@color:orange;padding-left:10px;float:left;$player2.name@@@@#player2LEVEL;color:orange;padding-right:2px;float:right;Lvl.$player2.level@@'' </div> <</if>> <</widget>> /* DISPLAYS PLAYER CURRENCY IN GOLD AND SILVER */ /* -------------------------------------------------- */ <<widget 'playerCurrency'>> <div class="currency-bar"> <center>''@@color:#ffd700;<<print Math.trunc(($player.currency/100)) + ' Gold'>>@@, @@color:#c0c0c0;<<print Math.trunc($player.currency%100) + ' Silver'>>@@''</center> </div> <</widget>> /* ------------------------------------------------------------------- */ /* DISPLAYS PLAYER EXPERIENCE BAR AND EXPERIENCE POINTS */ /* -------------------------------------------------- */ <<widget "playerXP">> <<set _player = $args[0]>> <div style="margin-bottom: 3px"> <<if _player is $player1>> <div id="player1-experience" class="green progress-bar"> <div style="top: 0; right: 5px; position: absolute; z-index: 1000; font-size: 0.8em"><b>@@#player1XP;$player1.thisLevelXP / $player1.nextLevelXP XP@@</b> </div> <span class="hp"></span> </div> <<else>> <div id="player2-experience" class="green progress-bar"> <div style="top: 0; right: 5px; position: absolute; z-index: 1000; font-size: 0.8em"><b>@@#player2XP;$player2.thisLevelXP / $player2.nextLevelXP XP@@</b> </div> <span class="hp"></span> </div> <</if>> </div> <</widget>> /* DISPLAYS PLAYER HEALTH BAR, NAME AND HEALTH POINTS */ /* -------------------------------------------------- */ <<widget "playerHP">> <<set _player = $args[0]>> <div style="margin-bottom: 3px"> <<if _player is $player1>> <div id="player1-health" class="red progress-bar"> <div style="top: 0; right: 5px; position: absolute; z-index: 1000; font-size: 0.8em"><b>@@#player1HP;$player1.hp / $player1.hpMax HP@@</b> </div> <span class="hp"></span> </div> <<else>> <div id="player2-health" class="red progress-bar"> <div style="top: 0; right: 5px; position: absolute; z-index: 1000; font-size: 0.8em"><b>@@#player2HP;$player2.hp / $player2.hpMax HP@@</b> </div> <span class="hp"></span> </div> <</if>> </div> <</widget>> /* DISPLAYS PLAYER MAGIC BAR, NAME AND MAGIC POINTS */ /* -------------------------------------------------- */ <<widget "playerMP">> <<set _player = $args[0]>> <div style="margin-bottom: 0"> <<if _player is $player1>> <div id="player1-magic" class="blue progress-bar"> <div style="top: 0; right: 5px; position: absolute; z-index: 1000; font-size: 0.8em"><b>@@#player1MP;$player1.mp / $player1.mpMax MP@@</b> </div> <span class="hp"></span> </div> <<else>> <div id="player2-magic" class="blue progress-bar"> <div style="top: 0; right: 5px; position: absolute; z-index: 1000; font-size: 0.8em"><b>@@#player2MP;_player.mp / _player.mpMax MP@@</b> </div> <span class="hp"></span> </div> <</if>> </div> <</widget>> <<widget "enemyHP">> /* DISPLAYS ENEMY HEALTH BAR, NAME AND HEALTH POINTS */ /* -------------------------------------------------- */ <b>The $enemy.name</b><br> <div id="enemy-health" class="red progress-bar"> <div style="top: 0; right: 5px; position: absolute; z-index: 1000; font-size: 0.8em"><b>@@#enemyHP;$enemy.hp / $enemy.hpMax HP@@</b></div> <span class="hp"></span> </div> <br> <</widget>>
<<widget 'turnCombat'>> <<addclass "#actionBar" "disable">> <<set _player = $args[0]>> <<set $turn++>> <<if $enemy.hp gt 0>> /* DAMAGE TO THE ENEMY */ /* ------------------- */ /* --- COMBAT SPELLS --- */ /* --------------------- */ <<if $castSpell is "firebolt">> /* Set the amount of base damage the player does to the enemy */ <<set _damageToEnemy to Math.max(1, Math.trunc(random(100)))>> /* Deals the actual damage to the enemy */ <<set $enemy.hp to Math.clamp($enemy.hp - _damageToEnemy, 0, $enemy.hpMax)>> /* The enemy targets the player that has dealt the most damage */ <<set _player.thisDamage += _damageToEnemy>> <<set _player.totalDamage += _damageToEnemy>> <<if $player1.thisDamage > $player2.thisDamage>> <<set _playerTargeted to $player1>> <<elseif $player1.thisDamage < $player2.thisDamage>> <<set _playerTargeted to $player2>> <<else>> <<set _playerTargeted to either($player1, $player2)>> <</if>> /* Logs a firebolt hit */ <<prepend #output>> ^^P$turn:^^ ''_player.name'' hits ''$enemy.name'' with a firebolt for ''_damageToEnemy'' damage!<br> <</prepend>> <<set $castSpell to "">> <<else>> /* --- MELEE/RANGED ATTACK --- */ /* --------------------------- */ /* Set the amount of base damage the player does to the enemy */ <<set _damageToEnemy to Math.max(2, random(_player.attack, Math.trunc(_player.attack + _player.weapon.attack)))>> /* Adds possible critical damage to base damage */ <<if random(1, 100) <= _player.crit>> <<set _damageToEnemy to Math.trunc(_damageToEnemy*1.5)>> <<set _crit to true>> <</if>> /* Deals the actual damage to the enemy */ <<set $enemy.hp to Math.clamp($enemy.hp - _damageToEnemy, 0, $enemy.hpMax)>> /* The enemy targets the player that has dealt the most damage */ <<set _player.thisDamage += _damageToEnemy>> <<set _player.totalDamage += _damageToEnemy>> <<if $player1.thisDamage > $player2.thisDamage>> <<set _playerTargeted to $player1>> <<elseif $player1.thisDamage < $player2.thisDamage>> <<set _playerTargeted to $player2>> <<else>> <<set _playerTargeted to either($player1, $player2)>> <</if>> /* Logs a critical hit */ <<if _crit>> <<prepend #output>> ^^P$turn:^^ ''_player.name'' critically hits ''$enemy.name'' for ''_damageToEnemy'' damage!<br> <</prepend>> */ Logs a regular hit */ <<else>> <<prepend #output>> ^^P$turn:^^ ''_player.name'' hits ''$enemy.name'' for ''_damageToEnemy'' damage!<br> <</prepend>> <</if>> <</if>> /* Updates the enemy health bar */ <<replace #enemyHP>>$enemy.hp / $enemy.hpMax HP<</replace>> <<run ProgressBar.updateBar('#enemy-health', $enemy.hpMax, $enemy.hp)>> /* CHECKS FOR THE DEFEAT OF THE ENEMY */ /* ---------------------------------- */ <<if $enemy.hp lte 0>> <<set $rewardBtn to true>> /* Log enemy kill and rewards */ <<prepend #output>> A ''$enemy.name'' was killed.<br> <</prepend>> /* Enable buttons */ <<removeclass "#actionBar" "disable">> /* Force updates all progress bars and statistics */ <<updateStats $player1>> <<updateStats $player2>> /* Force updates the actionBar */ <<script>>setPageElement("actionbar", "ActionBar");<</script>> <<else>> /* DAMAGE TO PLAYER CHARACTERS */ /* --------------------------- */ <<timed 500ms>> <<set _damageToPlayer to Math.max(2, Math.trunc(random($enemy.attack) *(100/(100+_playerTargeted.defense))))>> <<set _playerTargeted.hp to Math.clamp(_playerTargeted.hp - _damageToPlayer, 0, _playerTargeted.hpMax)>> /* Log damage to player */ <<prepend #output>> ^^E$turn:^^ The ''$enemy.name'' hits ''_playerTargeted.name'' for ''_damageToPlayer'' damage!<br> <</prepend>> /* CHECKS FOR THE DEFEAT OF THE PLAYER */ /* ----------------------------------- */ <<if $player1.hp lte 0>> <<prepend #output>> ''$player1.name'' was killed.<br> <</prepend>> <<popup 'popGameOver'>> <<elseif $player2.hp lte 0>> <<prepend #output>> ''$player2.name'' was killed.<br> <</prepend>> <<popup 'popGameOver'>> <</if>> /* Force updates all progress bars and statistics */ <<updateStats $player1>> <<updateStats $player2>> /* Enable buttons */ <<removeclass "#actionBar" "disable">> <</timed>> <</if>> <</if>> <</widget>>
You are standing on a narrow packed dirt road that runs through ''a forest''. As far as the eye can see are //<<= either("pine", "spruce", "birch")>>// trees to either side of the road. You also see the occasional //<<= either("oak", "elm", "maple")>>//.<br> <br> <<set _encounter to either(true,false)>> <<set $enemy to $enemyArray.random()>> <<set $enemy.hpMax to $enemy.hp>> <<if _encounter>> <<set $enemyPresent to true>> A ''$enemy.name'' is watching you closely. <<else>> <<set $enemyPresent to false>> You seem to be alone here. <</if>>
<<set $rewardBtn to false>> <<set $turn to 0>> <<set _addXP to random(50, 100)>> A ''$enemy.name'' was killed.<br> ''$player1.name'' did ''$player1.thisDamage'' damage and ''$player2.name'' did ''$player2.thisDamage'' damage.<br> /* The player that dealt more damage receives more experience */ <<if $player1.thisDamage > $player2.thisDamage>> <<set $player1.xp += Math.trunc(_addXP*0.75)>> <<set $player2.xp += Math.trunc(_addXP*0.25)>> <<else>> <<set $player1.xp += Math.trunc(_addXP*0.25)>> <<set $player2.xp += Math.trunc(_addXP*0.75)>> <</if>> You have received ''@@color:rgb(43,194,83);_addXP XP@@''.<br> You have found <<addCurrency 5 25>>.<br> /* Force updates all progress bars and statistics */ <<updateStats $player1>> <<updateStats $player2>> <<set _addItem to either("weapon", "armor", "none")>> <span id="displayItem"> <<if _addItem is "weapon">> <<newWeapon>> You found a ''_weapon.name.'' <br> <<elseif _addItem is "armor">> <<newArmor>> You found a ''_armor.name.'' <br> <</if>> </span> <br> <span id="output"></span>
<<widget "lastAction">> <<set _lastAction to $args[0]>> <<set $lastAction to _lastAction>> <<script>>setPageElement("actionbar", "ActionBar");<</script>> <</widget>>
<<widget 'popup'>> <<set _player to $args[1]>> <<run setup.popup.content($args[0])>> <<run setup.popup.open()>> <</widget>>
<<widget 'spellBook'>> <<set _player to $args[0]>> <<set _tier to $args[1]>> <<if _tier is "tier1">> <<button "MINOR HEALING">> <<castSpell _player "minor healing">><<run setup.popup.close()>> <</button>> (@@.blue;-10 MP@@)<br> <<if tags().includes("turnCombat")>> <<button "FIREBOLT">> <<castSpell _player "firebolt">><<run setup.popup.close()>> <</button>> (@@.blue;-10 MP@@) <<else>> <<button "FIREBOLT">> <</button>> (@@color:grey;NOT AVAILABLE@@) <</if>> <<elseif _tier is "tier2">> <<button "HEALING">> <<castSpell _player "healing">><<run setup.popup.close()>> <</button>> (@@.blue;-15 MP@@)<br> <<elseif _tier is "tier3">> <<button "MAJOR HEALING">> <<castSpell _player "major healing">><<run setup.popup.close()>> <</button>> (@@.blue;-20 MP@@)<br> <</if>> <</widget>>
<<widget 'backpack'>> <<set _tab to $args[0]>> <center>''You are carrying''</center> <br> <<if _tab is "weapons">> <<for _i, _obj range $inventory.filter(function(o) { return o && o.itemType === "weapon"; })>> <<set _id to "cmdbox" + _i>> <<capture _i, _id, _obj>> <div style="border: 1px solid darkorange"> <<button "☰">><<toggleclass `'#' + _id` "remove">><</button>> <<print _obj.name + ' (' + _obj.attack + ' damage)'>> <span @id="_id" class="remove"><br> <center> <<link "swap p1">> <<replaceWeapon $player1 _obj.id>> <<replace "#inventory">><<include 'popInventory'>><</replace>> <</link>> — <<link "discard">> <<run $inventory.deleteWith(function(o) { return o && o.id === _obj.id; })>> <<replace "#inventory">><<include 'popInventory'>><</replace>> <</link>> — <<link "swap p2">> <<replaceWeapon $player2 _obj.id>> <<replace "#inventory">><<include 'popInventory'>><</replace>> <</link>> </center> </span> </div> <</capture>> <</for>> <<elseif _tab is "armor">> <<for _i, _obj range $inventory.filter(function(o) { return o && o.itemType === "armor"; })>> <<set _id to "cmdbox" + _i>> <<capture _i, _id, _obj>> <div style="border: 1px solid darkorange"> <<button "☰">><<toggleclass `'#' + _id` "remove">><</button>> <<print _obj.name + ' (' + _obj.defense + ' defense)'>> <span @id="_id" class="remove"><br> <center> <<link "swap p1">> <<replaceArmor $player1 _obj.id>> <<replace "#inventory">><<include 'popInventory'>><</replace>> <</link>> — <<link "discard">> <<run $inventory.deleteWith(function(o) { return o && o.id === _obj.id; })>> <<replace "#inventory">><<include 'popInventory'>><</replace>> <</link>> — <<link "swap p2">> <<replaceArmor $player2 _obj.id>> <<replace "#inventory">><<include 'popInventory'>><</replace>> <</link>> </center> </span> </div> <</capture>> <</for>> <<elseif _tab is "items">> Some random items. <<elseif _tab is "default">> Crap, not this page again! <</if>> <</widget>>
<div id="splash"> PRE-ALPHA REL.<br> <div class="scaling-svg-container" style="padding-bottom: 0"> <<include "magister52logo.svg">> </div> <div id="loading" class="blink"> <<print either( "Regular loading expression...", "Releasing the Red Dragon...", "This is not the game you're looking for...", "¯\\\_(ツ)_/¯" )>> </div> </div>
/* THE ENTIRE SVG LOGO IN INLINE FORMAT WITH CSS CLASS BELOW */ <svg class="scaling-svg" viewBox="0 0 150 150"><g transform="translate(-30 -73)"><circle cy="149" cx="105" r="72" style="fill:#f4f7da;stroke-width:4;stroke:#9f0000"/><text y="184" x="49" style="fill:#9f0000;font-family:sans-serif;font-size:22px;letter-spacing:0px;line-height:130%;stroke-width:0.5px;word-spacing:0px"><tspan x="49" y="184"><tspan y="184" x="49" style="font-family:sans-serif;font-size:100px;font-weight:bold;line-height:130%;stroke-width:0.5px"> 52</tspan></tspan></text><rect height="23" width="120" y="135" x="45" fill="#f4f7da"/><text transform="scale(0.95 1.05)" y="148" x="51" style="fill:#9f0000;font-family:sans-serif;font-size:29px;letter-spacing:0px;line-height:130%;stroke-width:0.7;word-spacing:0px"><tspan x="51" y="148" stroke-width="0.7"><tspan y="148" x="51" style="font-family:sans-serif;font-size:23px;font-weight:bold;stroke-width:0.7"> MAGISTER</tspan></tspan></text></g></svg>
<div id="startpage"> <br> <br> <center> <h1>T O G E T H E R</h1> <h3>//A TALE OF TWO SIBLINGS//</h3> <br> <br> <<button "Start the game">> <<set document.getElementById("startpage").outerHTML = "">> <</button>> </center> </div>
You see a tavern here.<br> <br> The entrance looks welcoming.
<<set _isMale to either(true, false)>> <<set _diceCash to random(50,200)>> You are standing in the middle of a large common room.<br> <br> There are chairs and tables here.<br> <br> A suspicious looking //<<if _isMale>>man<<else>>woman<</if>>// is sitting in a chair and casually rolling and re-rolling a set of dice on the table-top. //<<if _isMale>>He<<else>>She<</if>>// beckons for you to come.
<popTop>PLAY DICE<<X>></popTop> Diceplayer's cash: ''@@color:#ffd700;<<print Math.trunc((_diceCash/100)) + ' Gold'>>@@, @@color:#c0c0c0;<<print Math.trunc(_diceCash%100) + ' Silver'>>@@'' <hr> <br> Present rules.<br> Bet cash.<br> Throw dice.<br> Win-lose<br>
<popTop>PLAY CARDS<<X>></popTop> Diceplayer's cash: ''@@color:#ffd700;<<print Math.trunc((_diceCash/100)) + ' Gold'>>@@, @@color:#c0c0c0;<<print Math.trunc(_diceCash%100) + ' Silver'>>@@'' <hr> <div style="display: flex; justify-content: space-between"> <div style="flex-basis: 20%">Player: @@#pScore;0@@</div> <div style="flex-basis: auto">ROUND: @@#round;1@@ / 3</div> <div style="flex-basis: 20%">Opponent: @@#oScore;0@@</div> </div> <hr><br> <div id="content"> The player draws cards from the deck and tries to come as close to 21 as possible before deciding to stop. Higher than 21 loses the round and exactly 21 automatically wins the round. Unless the player gets 21 the opponent then draws cards trying to come closer to 21 than the player in which case the player also loses the round.<br> <br> </div> <div id="links"> <center> <<button "Begin playing">> <<cards21Player>> <</button>> </center> </div> <hr> <div id="output"></div>
<<widget "cards21Player">> <<set _cards21Player to $args[0]>> <<set _maxRounds to 3>> /* Set inital values when no argument is supplied to widget */ <<if not _cards21Player>> /* Clone the deck (setup-object) and set up empty hands (arrays) */ <<set _deck to clone(setup.deck)>> <<set _playerCards to []>> <<set _opponentCards to []>> <<set _pScore to 0>> <<set _oScore to 0>> <<set _pRound to 0>> <<set _oRound to 0>> <<set _round to 1>> <<replace "#content">><</replace>> <<cards21Player "player">> <</if>> /* Rounds limited to _maxRound */ <<if _round lte _maxRounds>> /* Player's turn */ <<if _cards21Player is "player">> /* Clear output */ <<timed 0s>> <<replace "#output">><</replace>> <</timed>> /* Available actions */ <<timed 0s>> <<replace "#links">> <<link "Draw a card">> <<set _playerCards to _playerCards.concat(_deck.pluck())>> <<set _pRound += _playerCards.last().value>> /* Player bust */ <<if _pRound gt 21>> <<replace "#links">> Draw a card — <<link "End round">> <<set _round ++>> <<replace "#round">> <<= _round.clamp(1,_maxRounds) >> <</replace>> <<set _oScore ++>> <<replace "#oScore">> _oScore <</replace>> <<set _pRound to 0>> <<cards21Player "player">> <br> <</link>> <</replace>> <<replace "#output">> You draw ''<<=_playerCards.last().card>> of <<=_playerCards.last().suit>>'' from the deck.<br> You are bust at _pRound points and lose the round.<br> <</replace>> /* Player wins */ <<elseif _pRound is 21>> <<replace "#links">> Draw a card — <<link "End round">> <<set _round ++>> <<replace "#round">> <<= _round.clamp(1,_maxRounds) >> <</replace>> <<set _pScore ++>> <<replace "#pScore">> _pScore <</replace>> <<set _pRound to 0>> <<cards21Player "player">> <br> <</link>> <</replace>> <<replace "#output">> You draw ''<<=_playerCards.last().card>> of <<=_playerCards.last().suit>>'' from the deck.<br> You have _pRound points and win the round!<br> <</replace>> /* Player draws again */ <<else>> <<replace "#output">> You draw ''<<=_playerCards.last().card>> of <<=_playerCards.last().suit>>'' from the deck.<br> You are currently at _pRound points.<br> <</replace>> <</if>> <</link>> — <<link "End round">> <<replace "#links">> Draw a card — End round <</replace>> <<replace "#output">> You decide to stop here end the round.<br> You stopped at _pRound points.<br> <</replace>> <<timed "3000ms">> <<replace "#pScore">> _pScore <</replace>> <<cards21Player "opponent">> <</timed>> <br> <</link>> <br> <</replace>> <</timed>> /* Opponent's turn */ <<elseif _cards21Player is "opponent">> <<timed 0s>> <<replace "#links">> Opponent draws a card <</replace>> <</timed>> <<set _opponentCards to _opponentCards.concat(_deck.pluck())>> <<set _oRound += _opponentCards.last().value>> /* Opponent bust */ <<if _oRound gt 21>> <<timed 0s>> <<replace "#output">> <<timed "1000ms">> Your opponent draws ''<<=_opponentCards.last().card>> of <<=_opponentCards.last().suit>>'' from the deck.<br> They are bust at _oRound points and lose the round.<br> <</timed>> <<timed "3000ms">> <<if _round lt _maxRounds>> They end their turn.<br> <<else>> They end their round. That concludes the game.<br> <</if>> <</timed>> <</replace>> <</timed>> <<timed "5000ms">> <<set _round += 1>> <<replace "#round">> <<= _round.clamp(1,_maxRounds) >> <</replace>> <<set _pScore++>> <<replace "#pScore">> _pScore <</replace>> <<set _oRound to 0>> <<set _pRound to 0>> <<cards21Player "player">> <</timed>> /* Opponent wins */ <<elseif _oRound is 21 || _oRound gt _pRound>> <<timed 0s>> <<replace "#output">> <<timed "1000ms">> Your opponent draws ''<<=_opponentCards.last().card>> of <<=_opponentCards.last().suit>>'' from the deck.<br> They have _oRound points and win the round!<br> <</timed>> <<timed "3000ms">> <<if _round lt _maxRounds>> They win the round.<br> <<else>> They win the round. That concludes the game.<br> <</if>> <</timed>> <</replace>> <</timed>> <<timed "5000ms">> <<set _round += 1>> <<replace "#round">> <<= _round.clamp(1,_maxRounds) >> <</replace>> <<set _oScore++>> <<replace "#oScore">> _oScore <</replace>> <<set _oRound to 0>> <<set _pRound to 0>> <<cards21Player "player">> <</timed>> /* Opponent ends their turn */ <<else>> <<if _pRound lt _oRound>> <<timed 0s>> <<replace "#output">> <<timed "1000ms">> Your opponent draws ''<<=_opponentCards.last().card>> of <<=_opponentCards.last().suit>>'' from the deck.<br> Their round score is currently _oRound!<br> <</timed>> <<timed "3000ms">> <<if _round lt _maxRounds>> They win the round.<br> <<else>> They win the round. That concludes this game.<br> <</if>> <</timed>> <</replace>> <</timed>> <<timed "5000ms">> <<set _oRound to 0>> <<set _pRound to 0>> <<cards21Player "player">> <</timed>> /* The opponent draws again */ <<else>> <<timed 0s>> <<replace "#output">> <<timed "1000ms">> Your opponent draws a ''<<=_opponentCards.last().card>> of <<=_opponentCards.last().suit>>'' from the deck.<br> Their round score is currently _oRound.<br> <</timed>> <<timed "3000ms">> They draw another card from the deck.<br> <</timed>> <</replace>> <</timed>> <<timed "5000ms">> <<cards21Player "opponent">> <</timed>> <</if>> <</if>> <br> <</if>> /* The game has ended */ <<else>> <<timed 1s>> <<replace "#content">> The game has ended.<br> The player's total score is: _pScore<br> The opponent's total score is: _oScore<br> <br> The winner is <<if _pScore > _oScore>>''the player''<<else>>''the opponent''!<</if>> <</replace>> <<replace "#links">><</replace>> <<replace "#output">><</replace>> <</timed>> <</if>> <</widget>>
<popTop>PLAYER ACTIONS<<X>></popTop>