Eco Simulator
made by redlaserbmGraph
Nothing Here Yet :P
Always do this first!
Initial Game State
Starting Parameters
Starting Farms
Farm Indexes
Buy Queue
Buy Queue
Eco Queue
Eco Queue
#
#
#
deleteChildren('#farmSelect')
farmSelect = document.querySelector('#farmSelect')
if len(farmSlots) !=0:
for index, value in enumerate(farmSlots):
farmRadio = document.createElement('input')
farmRadio.type = 'radio'
farmRadio.name = 'farmIndex'
farmRadio.id = f"farm{index}"
farmRadio.value = index
radioLabel = document.createElement('label')
radioLabel.setAttribute('for', f"farm{index}")
radioLabel.innerText = f"Farm {index}"
farmSelect.appendChild(farmRadio)
farmSelect.appendChild(radioLabel)
buttons = document.querySelectorAll('#upgradeFarmButtons button')
for button in buttons:
button.disabled = False
else:
p = document.createElement('p')
p.textContent = "No farms :("
farmSelect.appendChild(p)
buttons = document.querySelectorAll('#upgradeFarmButtons button')
for button in buttons:
button.disabled = True
farmRadios = document.querySelectorAll('#farmSelect input')
for radio in farmRadios:
add_event_listener(radio, 'click', lambda e: updateFarmSegment(e))
def updateFarmSegment(e):
segments = document.querySelectorAll('#farmSelect label');
for segment in segments:
segment.classList.remove('pressed');
e.target.classList.add('pressed')
segment = document.querySelector('#farmSelect label[for='+e.target.id+']');
segment.classList.add('pressed');
ecoRadios = document.querySelectorAll('.sendsContainer input')
for radio in ecoRadios:
add_event_listener(radio, 'click', lambda e: updateEcoSegment(e))
def updateEcoSegment(e):
segments = document.querySelectorAll('.sendsContainer label');
for segment in segments:
segment.classList.remove('pressed');
e.target.classList.add('pressed')
segment = document.querySelector(".sendsContainer label[for=\'"+str(e.target.id)+"\']");
segment.classList.add('pressed');
def upgradePath(path):
cashBuffer = int(document.querySelector('#farmBuffer').value)
pathNum = int(path)
console.log(pathNum)
farmIndex = int(document.querySelector('input[name="farmIndex"]:checked').value)
buy_queue.append([upgradeFarm(farmIndex, pathNum-1, cashBuffer)])
renderBuyQueue()
setInitialState()
def farmSell():
farmIndex = int(document.querySelector('input[name="farmIndex"]:checked').value)
farm = document.querySelector('input[name="farmIndex"]:checked')
farm.disabled = True
console.log(farmIndex)
buy_queue.append([sellFarm(farmIndex)])
renderBuyQueue()
setInitialState()
def addToBuyQueue():
buyValue = float(Element('buyPriceInput').value)
buyBuffer = 0
if Element('buyBuffer').value != '':
buyBuffer = float(Element('buyBuffer').value)
buy_queue.append([buyDefense(buyValue, buyBuffer)])
renderBuyQueue()
setInitialState()
def renderBuyQueue():
deleteChildren('#buyQueue')
queue = document.querySelector('#buyQueue')
for buy in buy_queue:
buyContainer = document.createElement('div')
buyContainer.classList.add('buyContainer')
p = document.createElement('p')
# [{'Type': 'Buy Farm', 'Buffer': 0, 'Minimum Buy Time': 0, 'Message': 'Buy Farm'}]
for index in buy:
titleSpan = document.createElement('span')
titleSpan.classList.add('buyTitle')
buyTitle = f"{index['Message']}"
titleSpan.textContent = buyTitle
p.appendChild(titleSpan)
if index['Buffer'] != 0:
bufferSpan = document.createElement('span')
bufferSpan.classList.add('buyBuffer')
buyMessage = f" Buffer: ${index['Buffer']} "
bufferSpan.textContent = buyMessage
p.appendChild(bufferSpan)
button = document.createElement('button')
button.id = str(buy)
button.textContent = "Delete"
buyContainer.appendChild(p)
buyContainer.appendChild(button)
queue.appendChild(buyContainer)
proxy = create_proxy(lambda event: deleteBuy(event.target))
button.addEventListener("click", proxy)
def deleteBuy(button):
console.log(button.id)
buy = eval(button.id)
buy_queue.remove(buy)
console.log(buy[0]['Type'])
if buy[0]['Type'] == 'Buy Farm':
global farmsToBuy
farmsToBuy-=1
console.log(farmsToBuy)
updateFarmSlots()
renderFarmSlots();
renderBuyQueue()
def addToEcoQueue():
global rounds
roundNum = float(document.getElementById('ecoRound').value)
document.getElementById('ecoRound').value = float(Element('ecoRound').value)+1
sendTypeInput = document.querySelector('input[name="sendType"]:checked')
sendType = sendTypeInput.id
eco_queue.append((rounds.getTimeFromRound(roundNum), sendType))
renderEcoQueue()
setInitialState()
def deleteSend(button):
console.log(button.id)
eco_queue.remove(eval(button.id))
renderEcoQueue()
def renderEcoQueue():
deleteChildren('#ecoQueue')
queue = document.querySelector('#ecoQueue')
for ecoSend in sorted(eco_queue):
ecoContainer = document.createElement('div')
ecoContainer.classList.add('ecoContainer')
p = document.createElement('p')
console.log(ecoSend)
span = document.createElement('span')
span.classList.add('ecoTitle')
span.textContent = ecoSend[1]
timeSpan = document.createElement('span')
timeSpan.classList.add('ecoTime')
timeSpan.textContent = f" at {ecoSend[0]}s"
p.appendChild(span)
p.appendChild(timeSpan)
button = document.createElement('button')
button.id = str(ecoSend)
button.textContent = "Delete"
ecoContainer.appendChild(p)
ecoContainer.appendChild(button)
queue.appendChild(ecoContainer)
console.log(str(ecoSend))
proxy = create_proxy(lambda event: deleteSend(event.target))
button.addEventListener("click", proxy)
def runSim():
game_state = GameState(initial_state)
game_state.fastForward(target_round = float(Element('endRoundInput').value))
game_state.viewCashEcoHistory(dim = (18, 6))
setInitialState()
#
# no farms :(
#
#
#
#
#
#