Initializing repo
This commit is contained in:
commit
7df7802536
74
MonoLedger.py
Normal file
74
MonoLedger.py
Normal file
@ -0,0 +1,74 @@
|
||||
# A ledger and calculator for Monopoly games
|
||||
# Enables equal distributions to all (other) players
|
||||
# This was the original experiment
|
||||
|
||||
numPlayers = 0
|
||||
accounts = []
|
||||
# accounts[0] is the pot, players are after that
|
||||
|
||||
def printBalances():
|
||||
for account in accounts:
|
||||
print(account[0] + ": " + str(account[1]))
|
||||
|
||||
def initialize():
|
||||
global numPlayers
|
||||
global accounts
|
||||
numPlayers = int(input("How many players (>1)? "))
|
||||
if numPlayers < 2:
|
||||
initialize()
|
||||
return
|
||||
startingValue = int(input("How much for each player? "))
|
||||
accounts.append(["Pot",0])
|
||||
while len(accounts) < numPlayers + 1:
|
||||
i = len(accounts)
|
||||
accounts.append(["Player " + str(i), startingValue])
|
||||
print ("Created:\n")
|
||||
printBalances()
|
||||
print("Let the game begin!\n")
|
||||
|
||||
def play():
|
||||
global accounts
|
||||
playing = True
|
||||
while playing:
|
||||
option = input("[b]alances, [s]end, [q]uit: ")
|
||||
if option == "q":
|
||||
print("Game over!")
|
||||
playing = False
|
||||
if option == "b":
|
||||
printBalances()
|
||||
if option == "s":
|
||||
fromAcc = input("From (Choose pot, bank, or 1-" +
|
||||
str(numPlayers) + " for players): ")
|
||||
toAcc = input("To (Choose pot, bank, 1-" +
|
||||
str(numPlayers) +
|
||||
" for players, or all): ")
|
||||
amount = int((input("Amount (integer): ")))
|
||||
#DEBIT
|
||||
if fromAcc != "bank":
|
||||
if fromAcc == "pot":
|
||||
fromAcc = 0
|
||||
else:
|
||||
fromAcc = int(fromAcc)
|
||||
accounts[fromAcc][1] = accounts[fromAcc][1] - amount
|
||||
#CREDIT
|
||||
if toAcc != "bank":
|
||||
if toAcc == "all":
|
||||
remainder = amount
|
||||
i = 1
|
||||
while remainder > 0:
|
||||
if i != fromAcc:
|
||||
remainder -= 1
|
||||
accounts[i][1] += 1
|
||||
i += 1
|
||||
if i > numPlayers:
|
||||
i = 1
|
||||
else:
|
||||
if toAcc == "pot":
|
||||
toAcc = 0
|
||||
else:
|
||||
toAcc = int(toAcc)
|
||||
accounts[toAcc][1] = accounts[toAcc][1] + amount
|
||||
printBalances()
|
||||
|
||||
initialize()
|
||||
play()
|
149
MonopolyLedger.html
Normal file
149
MonopolyLedger.html
Normal file
@ -0,0 +1,149 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Monopoly Ledger</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Monopoly Ledger</h1>
|
||||
|
||||
<div id="output"></div>
|
||||
|
||||
<div id="transactions">
|
||||
|
||||
<h2>Transactions</h2>
|
||||
|
||||
<form id="form" onsubmit="event.preventDefault();">
|
||||
<label for="fromAcc">From:</label>
|
||||
<select id="fromAcc">
|
||||
<option value="pot">Pot</option>
|
||||
<option value="bank">Bank</option>
|
||||
<!-- Generate player options dynamically -->
|
||||
</select>
|
||||
<br>
|
||||
<label for="toAcc">To:</label>
|
||||
<select id="toAcc">
|
||||
<option value="pot">Pot</option>
|
||||
<option value="bank">Bank</option>
|
||||
<!-- Generate player options dynamically -->
|
||||
<option value="all">All</option>
|
||||
</select>
|
||||
<br>
|
||||
<label for="amount">Amount:</label>
|
||||
<input type="number" id="amount">
|
||||
<br>
|
||||
<button onclick="sendMoney()">Send</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var numPlayers = 0;
|
||||
var accounts = [];
|
||||
|
||||
function printBalances() {
|
||||
var output = document.getElementById("output");
|
||||
output.innerHTML = "";
|
||||
accounts.forEach(function(account) {
|
||||
output.innerHTML += account[0] + ": " + account[1] + "<br>";
|
||||
});
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
numPlayers = parseInt(prompt("How many players (>1)?"));
|
||||
if (numPlayers < 2) {
|
||||
initialize();
|
||||
return;
|
||||
}
|
||||
var startingValue = parseInt(prompt("How much for each player?"));
|
||||
accounts.push(["Pot", 0]);
|
||||
for (var i = 1; i <= numPlayers; i++) {
|
||||
accounts.push(["Player " + i, startingValue]);
|
||||
}
|
||||
console.log("Created:");
|
||||
printBalances();
|
||||
console.log("Let the game begin!");
|
||||
|
||||
generatePlayerOptions();
|
||||
}
|
||||
|
||||
function generatePlayerOptions() {
|
||||
var fromAccSelect = document.getElementById("fromAcc");
|
||||
var toAccSelect = document.getElementById("toAcc");
|
||||
|
||||
// Clear existing options
|
||||
fromAccSelect.innerHTML = "";
|
||||
toAccSelect.innerHTML = "";
|
||||
|
||||
// Add options for Pot and Bank
|
||||
var potOption = document.createElement("option");
|
||||
potOption.value = "pot";
|
||||
potOption.text = "Pot";
|
||||
fromAccSelect.add(potOption.cloneNode(true));
|
||||
toAccSelect.add(potOption.cloneNode(true));
|
||||
|
||||
var bankOption = document.createElement("option");
|
||||
bankOption.value = "bank";
|
||||
bankOption.text = "Bank";
|
||||
fromAccSelect.add(bankOption.cloneNode(true));
|
||||
toAccSelect.add(bankOption.cloneNode(true));
|
||||
|
||||
// Add player options
|
||||
for (var i = 1; i <= numPlayers; i++) {
|
||||
var playerOption = document.createElement("option");
|
||||
playerOption.value = i.toString();
|
||||
playerOption.text = "Player " + i;
|
||||
fromAccSelect.add(playerOption.cloneNode(true));
|
||||
toAccSelect.add(playerOption.cloneNode(true));
|
||||
}
|
||||
|
||||
// Add option for "All" to the "To" dropdown
|
||||
var allOption = document.createElement("option");
|
||||
allOption.value = "all";
|
||||
allOption.text = "All";
|
||||
toAccSelect.add(allOption.cloneNode(true));
|
||||
}
|
||||
|
||||
function sendMoney() {
|
||||
var fromAcc = document.getElementById("fromAcc").value;
|
||||
var toAcc = document.getElementById("toAcc").value;
|
||||
var amount = parseInt(document.getElementById("amount").value);
|
||||
|
||||
// DEBIT
|
||||
if (fromAcc !== "bank") {
|
||||
if (fromAcc === "pot") {
|
||||
fromAcc = 0;
|
||||
} else {
|
||||
fromAcc = parseInt(fromAcc);
|
||||
}
|
||||
accounts[fromAcc][1] -= amount;
|
||||
}
|
||||
|
||||
// CREDIT
|
||||
if (toAcc !== "bank") {
|
||||
if (toAcc === "all") {
|
||||
var remainder = amount;
|
||||
var i = 1;
|
||||
while (remainder > 0) {
|
||||
if (i !== fromAcc) {
|
||||
remainder -= 1;
|
||||
accounts[i][1] += 1;
|
||||
}
|
||||
i = (i % numPlayers) + 1;
|
||||
}
|
||||
} else {
|
||||
if (toAcc === "pot") {
|
||||
toAcc = 0;
|
||||
} else {
|
||||
toAcc = parseInt(toAcc);
|
||||
}
|
||||
accounts[toAcc][1] += amount;
|
||||
}
|
||||
}
|
||||
printBalances();
|
||||
}
|
||||
|
||||
initialize();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
32
README.md
Normal file
32
README.md
Normal file
@ -0,0 +1,32 @@
|
||||
# Monopoly Ledger
|
||||
|
||||
A Javascript tool to support more diverse rules for Monopoly not easy to implement with cash.
|
||||
|
||||
This project is in keeping with the original purpose of Monopoly's predecessor, The Landlord's Game, which was to demonstrate the effects of different economic rules.
|
||||
|
||||
Created with the assistance of ChatGPT based on an original Python prototype.
|
||||
|
||||
## Suggested rules
|
||||
|
||||
The following are example rule changes that can be tried up against the standard Parker Brothers rules.
|
||||
|
||||
### Goals
|
||||
|
||||
* All players win when each player builds a hotel
|
||||
|
||||
### Transactions
|
||||
|
||||
* Rents are paid to pot
|
||||
* Rents are paid to all other players
|
||||
* Pot distributed to a player who rolls doubles
|
||||
* Land tax paid to all other players on passing go (percentage of total property values)
|
||||
* Ban gifts and trades
|
||||
|
||||
## Citations
|
||||
|
||||
* [Coopoly](https://store.tesacollective.com/products/co-opoly-the-game-of-co-operatives) - "All players are on the same team and work together to start a cooperative business or organization and compete against the Point Bank"
|
||||
* [The Landlord's Game](https://landlordsgame.info/games/lg-1906/lg-1906_egc-rules.html) - The original version of Monopoly intended to teach Georgist idea, with several rule variants
|
||||
|
||||
## To do
|
||||
|
||||
* Do a game jam on alternative Monopoly rules, designing and testing them.
|
Loading…
x
Reference in New Issue
Block a user