<<set $bankBalance to 0>> <!-- Bank balance -->
<<set $interestRate to 0.01>> <!-- Interest rate per passage (1% here) -->
<<set $totalPassages to 0>> <!-- Total passages since deposit -->
<<set $lastInterestPassages to 0>> <!-- Passages since last interest added -->
<<set $ledger to []>> <!-- Transaction ledger -->
<<set $funds to 100>> <!-- Player funds for depositing -->
<<set $totalPassages += 1>>
<<if $totalPassages - $lastInterestPassages >= 1>>
<<set _interest = $bankBalance * $interestRate * ($totalPassages - $lastInterestPassages)>>
<<set $bankBalance += _interest>>
<<set $lastInterestPassages to $totalPassages>>
<<set $ledger.push({type: "Interest", amount: _interest, passage: $totalPassages})>>
<</if>>
:: Deposit
You currently have <<print $funds>> coins. Select an amount to deposit:
<div id="depositMessage">Make a deposit to see the updated balance.</div>
<<if $funds >= 10>><<link "Deposit 10 coins">>
<<if $funds >= 10>>
<<set $funds -= 10>>
<<set $bankBalance += 10>>
<<run $ledger.push({type: "Deposit", amount: 10, passage: Story.get("passage").title, location: "Central Bank"})>>
<<replace "#depositMessage">>
You have deposited 10 coins. Your new bank balance is <<print $bankBalance>> coins, and you have <<print $funds>> coins remaining.
<</replace>>
<<else>>
<<replace "#depositMessage">>You don’t have enough coins to deposit 10.<</replace>>
<</if>>
<</link>><br><<endif>>
<<if $funds >= 20>><<link "Deposit 20 coins">>
<<if $funds >= 20>>
<<set $funds -= 20>>
<<set $bankBalance += 20>>
<<run $ledger.push({type: "Deposit", amount: 20, passage: Story.get("passage").title, location: "Central Bank"})>>
<<replace "#depositMessage">>
You have deposited 20 coins. Your new bank balance is <<print $bankBalance>> coins, and you have <<print $funds>> coins remaining.
<</replace>>
<<else>>
<<replace "#depositMessage">>You don’t have enough coins to deposit 20.<</replace>>
<</if>>
<</link>><br><<endif>>
<<if $funds >= 50>><<link "Deposit 50 coins">>
<<if $funds >= 50>>
<<set $funds -= 50>>
<<set $bankBalance += 50>>
<<run $ledger.push({type: "Deposit", amount: 50, passage: Story.get("passage").title, location: "Central Bank"})>>
<<replace "#depositMessage">>
You have deposited 50 coins. Your new bank balance is <<print $bankBalance>> coins, and you have <<print $funds>> coins remaining.
<</replace>>
<<else>>
<<replace "#depositMessage">>You don’t have enough coins to deposit 50.<</replace>>
<</if>>
<</link>><br><<endif>>
[[View Bank Status|BankStatus]]
:: BankStatus
**Transaction History:**
<<for _entry range $ledger>>
<<print _entry.type>> of <<print _entry.amount>> coins at passage <<print _entry.passage>> in location <<print _entry.location>><br>
<</for>>
[[Deposit|Deposit]] | [[Withdraw|Withdraw]]
[[Entry]] Welcome to the bank!
[[Deposit]]
[[Withdraw]]
[[Ledger]]
[[ATM|Macro Interface]] :: BankStatus
**Current Funds:** <<print $funds>> coins
**Bank Balance:** <<print $bankBalance>> coins
**Transaction History:**
<<for _entry range $ledger>>
<<print _entry.type>> of <<print _entry.amount>> coins<br>
<</for>>
[[Deposit|Deposit]] | [[Withdraw|Withdraw]]
[[Entry]]
[[ATM|Macro Interface]] :: Withdraw
Your bank balance is <<print $bankBalance>> coins. Select an amount to withdraw:
<div id="withdrawMessage">Make a withdrawal to see the updated balance.</div>
<<if $bankBalance >= 10>><<link "Withdraw 10 coins">>
<<if $bankBalance >= 10>>
<<set $bankBalance -= 10>>
<<set $funds += 10>>
<<run $ledger.push({type: "Withdraw", amount: 10, passage: Story.get("passage").title, location: "Market Terminal #3"})>>
<<replace "#withdrawMessage">>
You have withdrawn 10 coins. Your new funds total is <<print $funds>> coins, and your bank balance is now <<print $bankBalance>> coins.
<</replace>>
<<else>>
<<replace "#withdrawMessage">>You don’t have enough in your bank balance to withdraw 10.<</replace>>
<</if>>
<</link>><br><<endif>>
<<if $bankBalance >= 20>><<link "Withdraw 20 coins">>
<<if $bankBalance >= 20>>
<<set $bankBalance -= 20>>
<<set $funds += 20>>
<<run $ledger.push({type: "Withdraw", amount: 20, passage: Story.get("passage").title, location: "Market Terminal #3"})>>
<<replace "#withdrawMessage">>
You have withdrawn 20 coins. Your new funds total is <<print $funds>> coins, and your bank balance is now <<print $bankBalance>> coins.
<</replace>>
<<else>>
<<replace "#withdrawMessage">>You don’t have enough in your bank balance to withdraw 20.<</replace>>
<</if>>
<</link>><br><<endif>>
<<if $bankBalance >= 50>><<link "Withdraw 50 coins">>
<<if $bankBalance >= 50>>
<<set $bankBalance -= 50>>
<<set $funds += 50>>
<<run $ledger.push({type: "Withdraw", amount: 50, passage: Story.get("passage").title, location: "Market Terminal #3"})>>
<<replace "#withdrawMessage">>
You have withdrawn 50 coins. Your new funds total is <<print $funds>> coins, and your bank balance is now <<print $bankBalance>> coins.
<</replace>>
<<else>>
<<replace "#withdrawMessage">>You don’t have enough in your bank balance to withdraw 50.<</replace>>
<</if>>
<</link>><br><<endif>>
[[View Bank Status|BankStatus]]
:: Bank Actions
Enter the amount to deposit or withdraw:
<input type="number" id="transactionAmount" placeholder="Enter amount">
<!-- Deposit Button -->
<<button "Deposit">>
<<bankTransaction "deposit" "Central Bank">>
<</button>>
<!-- Withdraw Button -->
<<button "Withdraw">>
<<bankTransaction "withdraw" "Central Bank">>
<</button>>
<!-- Display Transaction Result Here -->
<div id="transactionResult">Make a transaction to see the result here.</div>
[[View Bank Status|BankStatus]]