def processResearchReward(NATION_ARRAY, TECH_MAP, era, choice, researchedItemName, p, index, playerNationIndex): preferencePrint('', p, index, playerNationIndex) preferencePrint( str('######' + str(researchedItemName) + ' Research Complete! #########'), p, index, playerNationIndex) preferencePrint('', p, index, playerNationIndex) for item in TECH_MAP['EraBonus'][era][choice]: if item[0] == 'K': printLine = str('Knowledge boosted by ' + str(item[1]) + ' points.') NATION_ARRAY[index][0]['Tech']['knowledge'] += round(item[1]) if item[0] == 'R': printLine = str('Research boosted by ' + str(item[1]) + ' points.') NATION_ARRAY[index][0]['Tech']['research points'] += round(item[1]) if item[0] == 'W': printLine = str('Wealth increased by $' + str(item[1])) NATION_ARRAY[index][0]['Finance']['wealth'] += round(item[1]) preferencePrint(printLine, p, index, playerNationIndex) preferencePrint('', p, index, playerNationIndex) return (NATION_ARRAY)
def gainResearch(nextMove, NATION_ARRAY, TECH_MAP, currentNation, p, index, playerNationIndex, nextMoveIndex): pending = nextMove[0] job = nextMove[1] intensity = nextMove[2] investedPercent = nextMove[3] rounds = nextMove[4] invested = nextMove[5] RP = NATION_ARRAY[index][0]['Tech']['research points'] KP = NATION_ARRAY[index][0]['Tech']['knowledge'] if intensity == 'Soft': bonusRP = round((0.1 * RP)) if bonusRP < 25: bonusRP = 25 bonusKP = 0 elif intensity == 'Medium': bonusRP = round((0.1 * RP) + (invested / 3)) bonusKP = round((0.1 * KP) + (invested / 4)) elif intensity == 'Hard': bonusRP = round((0.2 * RP) + (invested / 5)) bonusKP = round((0.2 * KP) + (invested / 6)) elif intensity == 'Overtime': bonusRP = round((0.3 * RP) + (invested / 7)) bonusKP = round((0.3 * KP) + (invested / 8)) # IF ROUNDS STILL TO GO, REWARD BONUS AND CONTINUE PENDING if rounds > 0: rounds = rounds - 1 #ADD REWARDS NATION_ARRAY[index][0]['Tech']['research points'] += round(bonusRP) NATION_ARRAY[index][0]['Tech']['knowledge'] += round(bonusKP) nextMove = [ 'pending', job, intensity, investedPercent, rounds, invested ] NATION_ARRAY[index][0]['Nextmoves'][nextMoveIndex] = nextMove preferencePrint(str(str(NATION_ARRAY[index][1]) + ' Research Grant'), p, index, playerNationIndex) preferencePrint('------------------', p, index, playerNationIndex) preferencePrint(str('Level ' + str(intensity)), p, index, playerNationIndex) preferencePrint(str('RP Bonus : +' + str(bonusRP)), p, index, playerNationIndex) preferencePrint(str('KP Bonus : +' + str(bonusKP)), p, index, playerNationIndex) preferencePrint( str('RP increased from ' + str(RP) + ' to ' + str(NATION_ARRAY[index][0]['Tech']['research points'])), p, index, playerNationIndex) preferencePrint( str('KP increased from ' + str(KP) + ' to ' + str(NATION_ARRAY[index][0]['Tech']['knowledge'])), p, index, playerNationIndex) preferencePrint(str('Rounds Remaining : ' + str(rounds)), p, index, playerNationIndex) # Clear out nextmove if rounds == 0: NATION_ARRAY[index][0]['Nextmoves'][nextMoveIndex] = '' return (NATION_ARRAY) else: NATION_ARRAY[index][0]['Nextmoves'][nextMoveIndex] = '' return (NATION_ARRAY) return (NATION_ARRAY)
def processResearch(nextMove, NATION_ARRAY, TECH_MAP, currentNation, p, index, playerNationIndex, nextMoveIndex): pending = nextMove[0] job = nextMove[1] era = nextMove[2] choice = nextMove[3] required = nextMove[4] researchedItemName = currentNation[0]['Tech']['researched'][choice][1] remaining = required - currentNation[0]['Tech']['researched'][choice][0] pointsOwned = currentNation[0]['Tech']['research points'] pointsToSpend = round( currentNation[0]['Tech']['research points'] * 0.2 ) # Test the last number, it may need reduced: spend = devcompletion speed # Skip this move if not enough points if pointsOwned < pointsToSpend: print('Not enough points') return (NATION_ARRAY) # Skip if already max if remaining < 1: #print('Already Maxed out') return (NATION_ARRAY) # Deduct RP NATION_ARRAY[index][0]['Tech']['research points'] -= pointsToSpend # Update points earned NATION_ARRAY[index][0]['Tech']['researched'][choice][0] += pointsToSpend # Completion percent NATION_ARRAY[index][0]['Tech']['researched'][choice][2] = round( (currentNation[0]['Tech']['researched'][choice][0] / required) * 100) #Update remaining remaining = required - currentNation[0]['Tech']['researched'][choice][0] # update pointsOwned = currentNation[0]['Tech']['research points'] preferencePrint(str(str(NATION_ARRAY[index][1]) + ' Research Update'), p, index, playerNationIndex) preferencePrint('------------------', p, index, playerNationIndex) preferencePrint(str('Researched Item: ' + str(researchedItemName)), p, index, playerNationIndex) #preferencePrint(str('Research points spent = ' + str(pointsToSpend)),p,index,playerNationIndex) #preferencePrint(str('Research: remaining = ' + str(remaining) + ' , completion %' + str(currentNation[0]['Tech']['researched'][choice][2]) + '%'),p,index,playerNationIndex) #preferencePrint(str('Research: pointsOwned = ' + str(pointsOwned)),p,index,playerNationIndex) # process reward if remaining < 1: NATION_ARRAY[index][0]['Tech']['researched'][choice][2] = 100 NATION_ARRAY[index][0]['Nextmoves'][nextMoveIndex] = '' NATION_ARRAY = processResearchReward(NATION_ARRAY, TECH_MAP, era, choice, researchedItemName, p, index, playerNationIndex) else: # Continue the move nextMove = ['pending', job, era, choice, required] NATION_ARRAY[index][0]['Nextmoves'][nextMoveIndex] = nextMove preferencePrint( str('Completion ' + str(NATION_ARRAY[index][0]['Tech']['researched'][choice][2]) + '%'), p, index, playerNationIndex) return (NATION_ARRAY)
def promotion(currentNation, p, index, playerNationIndex): warRank = [ 'Private', 'Lieutenant', 'Captain', 'Major', 'Commander', 'General', 'Supreme Commander' ] might = currentNation[0]['War']['might'] rank = currentNation[0]['War']['level'] if might > 150 and rank == warRank[0]: currentNation[0]['War']['level'] = warRank[1] rank = currentNation[0]['Finance']['level'] currentNation[0]['Special']['notes'].append('warLevel') preferencePrint( str(currentNation[1]) + ' levelled up! New War rank is ' + str(currentNation[0]['War']['level']), p, index, playerNationIndex) if might > 300 and rank == warRank[1]: currentNation[0]['War']['level'] = warRank[2] rank = currentNation[0]['Finance']['level'] currentNation[0]['Special']['notes'].append('warLevel') preferencePrint( str(currentNation[1]) + ' levelled up! New War rank is ' + str(currentNation[0]['War']['level']), p, index, playerNationIndex) if might > 500 and rank == warRank[2]: currentNation[0]['War']['level'] = warRank[3] rank = currentNation[0]['Finance']['level'] currentNation[0]['Special']['notes'].append('warLevel') preferencePrint( str(currentNation[1]) + ' levelled up! New War rank is ' + str(currentNation[0]['War']['level']), p, index, playerNationIndex) if might > 800 and rank == warRank[3]: currentNation[0]['War']['level'] = warRank[4] rank = currentNation[0]['Finance']['level'] currentNation[0]['Special']['notes'].append('warLevel') preferencePrint( str(currentNation[1]) + ' levelled up! New War rank is ' + str(currentNation[0]['War']['level']), p, index, playerNationIndex) if might > 2000 and rank == warRank[4]: currentNation[0]['War']['level'] = warRank[5] rank = currentNation[0]['Finance']['level'] currentNation[0]['Special']['notes'].append('warLevel') preferencePrint( str(currentNation[1]) + ' levelled up! New War rank is ' + str(currentNation[0]['War']['level']), p, index, playerNationIndex) if might > 5000 and rank == warRank[5]: currentNation[0]['War']['level'] = warRank[6] rank = currentNation[0]['Finance']['level'] currentNation[0]['Special']['notes'].append('warLevel') preferencePrint( str(currentNation[1]) + ' levelled up! New War rank is ' + str(currentNation[0]['War']['level']), p, index, playerNationIndex) return (currentNation)
def advanceEra(nextMove, NATION_ARRAY, TECH_MAP, WAR_BRIEFING, currentNation, p, index, playerNationIndex, nextMoveIndex): era = currentNation[0]['Tech']['era'] nextEra = TECH_MAP['nextEra'][era] NATION_ARRAY[index][0]['Tech']['era'] = nextEra NATION_ARRAY[index][0]['Tech']['researched'] = { 'one': [0, '', 0], 'two': [0, '', 0], 'three': [0, '', 0], 'four': [0, '', 0], 'five': [0, '', 0] } NATION_ARRAY = updateTechNames(NATION_ARRAY, TECH_MAP) # REWARD KNOWLEDGE.. NATION_ARRAY[index][0]['Tech']['knowledge'] += round( (NATION_ARRAY[index][0]['Tech']['knowledge'] * 0.1)) #['conscripts','power','price','buildTime',['mightBonus%']] # Convert all units to might # REWARD MIGHT mightBonus = 0 quantityTotal = 0 for x in range(1, len(NATION_ARRAY[index][0]['War']['weapons']) + 1): quantity = NATION_ARRAY[index][0]['War']['weapons'][str(x)][1] level = NATION_ARRAY[index][0]['War']['weapons'][str(x)][2] power = NATION_ARRAY[index][0]['War']['weapons'][str(x)][3] quantityTotal += quantity total = quantity * level * power mightBonus += total NATION_ARRAY[index][0]['War']['might'] += mightBonus # # UPDATING WAR ARRAY UNITONE = WAR_BRIEFING['weapons'][nextEra]['1'] UNITTWO = WAR_BRIEFING['weapons'][nextEra]['2'] UNITTHREE = WAR_BRIEFING['weapons'][nextEra]['3'] UNITFOUR = WAR_BRIEFING['weapons'][nextEra]['4'] UNITFIVE = WAR_BRIEFING['weapons'][nextEra]['5'] UNITSIX = WAR_BRIEFING['weapons'][nextEra]['6'] UNITSEVEN = WAR_BRIEFING['weapons'][nextEra]['7'] UNITEIGHT = WAR_BRIEFING['weapons'][nextEra]['8'] NATION_ARRAY[index][0]['War']['weapons'] = { '1': [UNITONE[0], 0, 1, UNITONE[2]], '2': [UNITTWO[0], 0, 1, UNITTWO[2]], '3': [UNITTHREE[0], 0, 1, UNITTHREE[2]], '4': [UNITFOUR[0], 0, 1, UNITFOUR[2]], '5': [UNITFIVE[0], 0, 1, UNITFIVE[2]], '6': [UNITSIX[0], 0, 1, UNITSIX[2]], '7': [UNITSEVEN[0], 0, 1, UNITSEVEN[2]], '8': [UNITEIGHT[0], 0, 1, UNITEIGHT[2]] } preferencePrint('++++++++++++++++++++++++++++++++++++++++++', p, index, playerNationIndex) preferencePrint( str( str(NATION_ARRAY[index][1]) + ' has advanced to the ' + str(nextEra)), p, index, playerNationIndex) preferencePrint('++++++++++++++++++++++++++++++++++++++++++', p, index, playerNationIndex) preferencePrint('', p, index, playerNationIndex) preferencePrint( str(str(NATION_ARRAY[index][1]) + ' gained 10% knowledge.'), p, index, playerNationIndex) preferencePrint( str( str(quantityTotal) + ' units converted to +' + str(mightBonus) + ' might.'), p, index, playerNationIndex) preferencePrint( str( str(NATION_ARRAY[index][1]) + ' now has ' + str(nextEra) + ' level military capabilities.'), p, index, playerNationIndex) return (NATION_ARRAY)
def espionage(nextMove, NATION_ARRAY, currentNation, p, index, playerNationIndex): nationChoice = nextMove[1] bonusPercent = random.randint(1, 10) NATION_ARRAY[nationChoice][0]['Nextmoves'] = ['sabotaged'] currentNation[0] print() preferencePrint( str( str(NATION_ARRAY[nationChoice][1]) + ' has been infiltrated by an unknown advisary'), p, index, playerNationIndex) preferencePrint('===========================================', p, index, playerNationIndex) preferencePrint( str( str(NATION_ARRAY[nationChoice][1]) + ' current actions sabotaged and will miss a round.'), p, index, playerNationIndex) if currentNation[1] == NATION_ARRAY[playerNationIndex][1]: preferencePrint( str( str(currentNation[1]) + ' gained ' + str(bonusPercent) + '% might.'), p, index, playerNationIndex) preferencePrint( str( str(currentNation[1]) + ' original might value: ' + str(currentNation[0]['War']['might'])), p, index, playerNationIndex) currentNation[0]['War']['might'] = round( currentNation[0]['War']['might'] + (currentNation[0]['War']['might'] * (bonusPercent / 100))) if currentNation[1] == NATION_ARRAY[playerNationIndex][1]: preferencePrint( str( str(currentNation[1]) + ' new might value: ' + str(currentNation[0]['War']['might'])), p, index, playerNationIndex) discoverRisk = random.randint(0, 5) if discoverRisk == 2: preferencePrint('', p, index, playerNationIndex) preferencePrint( str( str(NATION_ARRAY[nationChoice][1]) + ' captured the insurgent from ' + str(currentNation[1])), p, index, playerNationIndex) preferencePrint('===========================================', p, index, playerNationIndex) preferencePrint( str( str(NATION_ARRAY[nationChoice][1]) + ' friendship with ' + str(currentNation[1] + ' has decreased as a result.')), p, index, playerNationIndex) preferencePrint( str( str(NATION_ARRAY[nationChoice][1]) + ' original friendship value: ' + str(NATION_ARRAY[nationChoice][0]['Friendship'][ currentNation[1]]['level'])), p, index, playerNationIndex) NATION_ARRAY[nationChoice][0]['Friendship'][currentNation[1]][ 'level'] = NATION_ARRAY[nationChoice][0]['Friendship'][ currentNation[1]]['level'] - random.randint(1, 18) preferencePrint( str( str(NATION_ARRAY[nationChoice][1]) + ' new friendship value: ' + str(NATION_ARRAY[nationChoice][0]['Friendship'][ currentNation[1]]['level'])), p, index, playerNationIndex) return (NATION_ARRAY)
def build(nextMove, NATION_ARRAY, currentNation, p, index, playerNationIndex, nextMoveIndex): pending = nextMove[0] job = nextMove[1] unit = nextMove[2] amount = nextMove[3] wait = nextMove[4] bonusMight = nextMove[5] moveIndex = nextMoveIndex # Get position in country array name = NATION_ARRAY[index][0]['War']['weapons'][unit][0] # IF NOT YET READY # DECREMENT BUILD TIME if wait > 1: wait = wait - 1 preferencePrint(str(str(currentNation[1]) + ' chose to build '), p, index, playerNationIndex) preferencePrint('------------------', p, index, playerNationIndex) preferencePrint(str(str(name) + ' to build : ' + str(amount)), p, index, playerNationIndex) preferencePrint(str('Build Time Remaining : ' + str(wait)), p, index, playerNationIndex) nextMove = ['pending', job, unit, amount, wait, bonusMight] NATION_ARRAY[index][0]['Nextmoves'][moveIndex] = nextMove return (NATION_ARRAY) # IF READY (currently at 2 cus lazy) if wait < 2: # Reward Unit NATION_ARRAY[index][0]['War']['weapons'][unit][1] += amount # Reward Mightg bonusAdjustment = round( (NATION_ARRAY[index][0]['War']['might'] * bonusMight) * (amount / 2)) if bonusAdjustment < 1: bonusAdjustment = 1 NATION_ARRAY[index][0]['War'][ 'might'] = NATION_ARRAY[index][0]['War']['might'] + bonusAdjustment preferencePrint(str(str(currentNation[1]) + ' Build complete '), p, index, playerNationIndex) preferencePrint('------------------', p, index, playerNationIndex) preferencePrint(str(str(name) + ' units built: ' + str(amount)), p, index, playerNationIndex) preferencePrint( str( str(name) + ' total : ' + str(NATION_ARRAY[index][0]['War']['weapons'][unit][1])), p, index, playerNationIndex) preferencePrint(str('Might gained : ' + str(bonusAdjustment)), p, index, playerNationIndex) preferencePrint( str('Might total : ' + str(currentNation[0]['War']['might'])), p, index, playerNationIndex) # Clear out existing array element NATION_ARRAY[index][0]['Nextmoves'][moveIndex] = [] return (NATION_ARRAY) return (NATION_ARRAY)
def scrap(nextMove, NATION_ARRAY, currentNation, p, index, playerNationIndex): job = nextMove[0] unit = nextMove[1] amount = nextMove[2] valuation = nextMove[3] reducedMight = nextMove[4] name = NATION_ARRAY[index][0]['War']['weapons'][unit][0] preferencePrint(str(str(currentNation[1]) + ' chose to scrap'), p, index, playerNationIndex) preferencePrint('------------------', p, index, playerNationIndex) preferencePrint(str(str(name) + ' to scrap : ' + str(amount)), p, index, playerNationIndex) # Award Credits and reduce might NATION_ARRAY[index][0]['Finance']['wealth'] += valuation Adjustment = round( (NATION_ARRAY[index][0]['War']['might'] * reducedMight) * (amount / 5)) NATION_ARRAY[index][0]['War']['might'] -= Adjustment preferencePrint(str('Might lost : -' + str(Adjustment)), p, index, playerNationIndex) preferencePrint( str('Might total : ' + str(currentNation[0]['War']['might'])), p, index, playerNationIndex) preferencePrint(str(str(currentNation[1]) + ' was paid ' + str(valuation)), p, index, playerNationIndex) preferencePrint( str('Credits total : ' + str(currentNation[0]['Finance']['wealth'])), p, index, playerNationIndex) return (NATION_ARRAY)
def drill(nextMove, NATION_ARRAY, currentNation, p, index, playerNationIndex): move = nextMove[0] branch = nextMove[1] intensity = nextMove[2] units = nextMove[3] might = NATION_ARRAY[index][0]['War']['might'] credits = NATION_ARRAY[index][0]['Finance']['wealth'] techLevel = NATION_ARRAY[index][0]['Tech']['level'] #['drill',branch,'soft',units] #units = [('troops',troops),('tanks',tanks)] # RETURN UNITS for unit, quantity in units: NATION_ARRAY[index][0]['War']['weapons'][unit][1] = quantity preferencePrint('', p, index, playerNationIndex) preferencePrint( str(str(currentNation[1]) + ' chose to train their ' + str(branch)), p, index, playerNationIndex) preferencePrint('================================', p, index, playerNationIndex) preferencePrint(str('Intensity: ' + str(intensity)), p, index, playerNationIndex) if intensity == 'soft': bonusMight = round((random.randint(1, 8) / 100) * might) NATION_ARRAY[index][0]['War']['might'] += bonusMight preferencePrint(str('Might gained : ' + str(bonusMight)), p, index, playerNationIndex) preferencePrint( str('New Might Total : ' + str(NATION_ARRAY[index][0]['War']['might'])), p, index, playerNationIndex) return (NATION_ARRAY) if intensity == 'medium': # WIN MIGTH bonusMight = round((random.randint(8, 14) / 100) * might) NATION_ARRAY[index][0]['War']['might'] += bonusMight # WIN CREDITS bonusCredits = round((random.randint(1, 5) / 100) * credits) NATION_ARRAY[index][0]['Finance']['wealth'] += bonusCredits preferencePrint( str( str(NATION_ARRAY[index][-1]) + ' impressed the top leadership and won financial backing.'), p, index, playerNationIndex) preferencePrint(str('Credits gained : ' + str(bonusCredits)), p, index, playerNationIndex) # LOSE A PORTION OF UNITS lossProbability = random.randint(0, 8) lossAmount = 0.25 flag = 'True' if lossProbability == 3: for unit, quantity in units: if quantity < 1: continue if random.randint(0, 2) == 1: continue loss = round(quantity * (random.randint(1, 25) / 100)) if loss < 1: loss = 1 if flag == 'True': preferencePrint( str('XXXX UNITS LOST IN TRAINING - DRILLED TO HARD XXXX' ), p, index, playerNationIndex) flag = 'False' preferencePrint( str( str( str(NATION_ARRAY[index][0]['War']['weapons'][unit] [0])) + ' lost in combat excercise '), p, index, playerNationIndex) preferencePrint( str( str(loss) + ' ' + str(NATION_ARRAY[index][0]['War'] ['weapons'][unit][0]) + ' lost'), p, index, playerNationIndex) preferencePrint(str(str(quantity - loss) + ' remaining'), p, index, playerNationIndex) NATION_ARRAY[index][0]['War']['weapons'][unit][1] -= loss preferencePrint(str('Might gained : ' + str(bonusMight)), p, index, playerNationIndex) preferencePrint( str('New Might Total : ' + str(NATION_ARRAY[index][0]['War']['might'])), p, index, playerNationIndex) return (NATION_ARRAY) if intensity == 'hard': # GAIN MIGHT bonusMight = round((random.randint(14, 20) / 100) * might) NATION_ARRAY[index][0]['War']['might'] += bonusMight # GAIN CREDITS bonusCredits = round((random.randint(5, 10) / 100) * credits) NATION_ARRAY[index][0]['Finance']['wealth'] += bonusCredits preferencePrint( str( str(NATION_ARRAY[index][-1]) + ' impressed the top leadership and won financial backing.'), p, index, playerNationIndex) preferencePrint(str('Credits gained : ' + str(bonusCredits)), p, index, playerNationIndex) # LOSE A PORTION OF UNITS lossProbability = random.randint(0, 4) lossAmount = 0.25 flag = 'True' if lossProbability == 3: for unit, quantity in units: if quantity < 1: continue if random.randint(0, 2) == 1: continue loss = round(quantity * (random.randint(1, 25) / 100)) if loss < 1: loss = 1 if flag == 'True': preferencePrint( str('XXXX UNITS LOST IN TRAINING - DRILLED TO HARD XXXX' ), p, index, playerNationIndex) flag = 'False' preferencePrint( str( str( str(NATION_ARRAY[index][0]['War']['weapons'][unit] [0])) + ' lost in combat excercise '), p, index, playerNationIndex) preferencePrint( str( str(loss) + ' ' + str(NATION_ARRAY[index][0]['War'] ['weapons'][unit][0]) + ' lost'), p, index, playerNationIndex) preferencePrint(str(str(quantity - loss) + ' remaining'), p, index, playerNationIndex) NATION_ARRAY[index][0]['War']['weapons'][unit][1] -= loss preferencePrint(str('Might gained : ' + str(bonusMight)), p, index, playerNationIndex) preferencePrint( str('New Might Total : ' + str(NATION_ARRAY[index][0]['War']['might'])), p, index, playerNationIndex) preferencePrint(str(''), p, index, playerNationIndex) # WIN BONUS UNITS winProbability = random.randint(0, 5) winProbability = 5 if winProbability == 5: # Update to include techlevel & Eon allowedAssets = allowedTech(currentNation) bonus = random.choice(allowedAssets) preferencePrint( str('**BONUS** The brass have gifted ' + str(NATION_ARRAY[index][1]) + ' ' + str(bonus[1]) + ' ' + str(NATION_ARRAY[index][0]['War']['weapons'][bonus[0]][0]) ), p, index, playerNationIndex) NATION_ARRAY[index][0]['War']['weapons'][bonus[0]][1] += bonus[1] return (NATION_ARRAY) return (NATION_ARRAY)
def sellAction(nextMove,NATION_ARRAY,currentNation,PRICE_TRACKER,p,index,playerNationIndex): commodity = nextMove[1] amount = nextMove[2] value = nextMove[3] preferencePrint(str(str(currentNation[1]) + ' chose to sell'),p,index,playerNationIndex) preferencePrint('------------------',p,index,playerNationIndex) preferencePrint(str('Credits : ' + str(currentNation[0]['Finance']['wealth'])),p,index,playerNationIndex) preferencePrint(str(str(commodity) + ' owned : ' + str(currentNation[0]['Finance'][commodity])),p,index,playerNationIndex) preferencePrint(str(str(commodity) + ' sold : ' + str(amount)),p,index,playerNationIndex) # UPDATE Increase stock and credit user PRICE_TRACKER[commodity]['stock'] = PRICE_TRACKER[commodity]['stock'] + amount NATION_ARRAY[index][0]['Finance']['wealth'] = NATION_ARRAY[index][0]['Finance']['wealth'] + value preferencePrint(str(str(currentNation[1]) + ' was paid ' + str(value)),p,index,playerNationIndex) preferencePrint(str('New Credits Total : ' + str(currentNation[0]['Finance']['wealth'])),p,index,playerNationIndex) return(NATION_ARRAY,PRICE_TRACKER)
def investResource(nextMove,NATION_ARRAY,currentNation,PRICE_TRACKER,p,index,playerNationIndex,nextMoveIndex): pending = nextMove[0] job = nextMove[1] resource = nextMove[2] spendAmount = nextMove[3] investedPrice = nextMove[4] wait = nextMove[5] moveIndex = nextMoveIndex # Get position in country array #[['Submitted','investResource',resource,spendAmount,investedPrice,wait]] # IF NOT YET READY if wait > 0: wait = wait -1 preferencePrint(str(str(currentNation[1]) + ' chose to Invest in ' + str(resource)),p,index,playerNationIndex) preferencePrint('------------------',p,index,playerNationIndex) preferencePrint(str('Time Remaining : ' + str(wait)),p,index,playerNationIndex) nextMove = ['pending',job,resource,spendAmount,investedPrice,wait] NATION_ARRAY[index][0]['Nextmoves'][moveIndex] = nextMove if wait < 1: currentPrice = PRICE_TRACKER[resource]['price'] priceDiff = currentPrice - investedPrice original = currentNation[0]['Finance']['wealth'] if priceDiff > 0: bonus = round(priceDiff * spendAmount * (random.randint(1,300)/100)) NATION_ARRAY[index][0]['Finance']['wealth'] = NATION_ARRAY[index][0]['Finance']['wealth'] + bonus preferencePrint(str(str(currentNation[1]) + ' made a profit of $' + str(bonus)),p,index,playerNationIndex) if priceDiff < 0: priceDiff = -priceDiff token = round((priceDiff/investedPrice) * investedPrice) loss = round(spendAmount - token) NATION_ARRAY[index][0]['Finance']['wealth'] = NATION_ARRAY[index][0]['Finance']['wealth'] + loss preferencePrint(str(str(currentNation[1]) + ' made a loss, but recouped $' + str(loss)),p,index,playerNationIndex) if priceDiff == 0: token = round(investedPrice + (investedPrice * (random.randint(1,18)/100))) NATION_ARRAY[index][0]['Finance']['wealth'] = NATION_ARRAY[index][0]['Finance']['wealth'] + token + spendAmount preferencePrint(str(str(currentNation[1]) + ' made no profit, but gained token interest of $' + str(token)),p,index,playerNationIndex) preferencePrint(str('Credits changed from $' + str(original) + ' to $' + str(currentNation[0]['Finance']['wealth'])),p,index,playerNationIndex) NATION_ARRAY[index][0]['Nextmoves'][moveIndex] = [] return(NATION_ARRAY)
def buyAction(nextMove,NATION_ARRAY,currentNation,PRICE_TRACKER,p,index,playerNationIndex): commodity = nextMove[1] amount = nextMove[2] cost = amount * PRICE_TRACKER[commodity]['price'] preferencePrint(str(str(currentNation[1]) + ' chose to buy '),p,index,playerNationIndex) preferencePrint('------------------',p,index,playerNationIndex) preferencePrint(str('Credits : ' + str(currentNation[0]['Finance']['wealth'])),p,index,playerNationIndex) preferencePrint(str(str(commodity) + ' purchased : ' + str(amount)),p,index,playerNationIndex) preferencePrint(str('Total Cost :' + str(cost)),p,index,playerNationIndex) # UPDATE Reduce stock and deliver goods to user PRICE_TRACKER[commodity]['stock'] = PRICE_TRACKER[commodity]['stock'] - amount NATION_ARRAY[index][0]['Finance'][commodity] = NATION_ARRAY[index][0]['Finance'][commodity] + amount preferencePrint(str('New total : ' + str(NATION_ARRAY[index][0]['Finance'][commodity])),p,index,playerNationIndex) return(NATION_ARRAY,PRICE_TRACKER)
def promotion(currentNation,p,index,playerNationIndex): financeRank = ['PickPocket', 'Penny Pusher', 'Assistant', 'gambler', 'accountant', 'huslter', 'business magnate'] wealth = currentNation[0]['Finance']['wealth'] rank = currentNation[0]['Finance']['level'] if wealth > 5100 and rank == financeRank[0]: currentNation[0]['Finance']['level'] = financeRank[1] rank = currentNation[0]['Finance']['level'] currentNation[0]['Special']['notes'].append('financeLevel') preferencePrint(str(currentNation[1] ) + ' levelled up! New Finance rank is ' + str(currentNation[0]['Finance']['level']),p,index,playerNationIndex) if wealth > 10000 and rank == financeRank[1]: currentNation[0]['Finance']['level'] = financeRank[2] rank = currentNation[0]['Finance']['level'] currentNation[0]['Special']['notes'].append('financeLevel') preferencePrint(str(currentNation[1] ) + ' levelled up! New Finance rank is ' + str(currentNation[0]['Finance']['level']),p,index,playerNationIndex) if wealth > 15000 and rank == financeRank[2]: currentNation[0]['Finance']['level'] = financeRank[3] rank = currentNation[0]['Finance']['level'] currentNation[0]['Special']['notes'].append('financeLevel') preferencePrint(str(currentNation[1] ) + ' levelled up! New Finance rank is ' + str(currentNation[0]['Finance']['level']),p,index,playerNationIndex) if wealth > 20000 and rank == financeRank[3]: currentNation[0]['Finance']['level'] = financeRank[4] rank = currentNation[0]['Finance']['level'] currentNation[0]['Special']['notes'].append('financeLevel') preferencePrint(str(currentNation[1] ) + ' levelled up! New Finance rank is ' + str(currentNation[0]['Finance']['level']),p,index,playerNationIndex) if wealth > 30000 and rank == financeRank[4]: currentNation[0]['Finance']['level'] = financeRank[5] rank = currentNation[0]['Finance']['level'] currentNation[0]['Special']['notes'].append('financeLevel') preferencePrint(str(currentNation[1] ) + ' levelled up! New Finance rank is ' + str(currentNation[0]['Finance']['level']),p,index,playerNationIndex) if wealth > 40000 and rank == financeRank[5]: currentNation[0]['Finance']['level'] = financeRank[6] rank = currentNation[0]['Finance']['level'] currentNation[0]['Special']['notes'].append('financeLevel') preferencePrint('****' + str(currentNation[1] ) + ' levelled up!***** New Finance rank is ' + str(currentNation[0]['Finance']['level']),p,index,playerNationIndex) return(currentNation)
def gambleAction(nextMove,NATION_ARRAY,currentNation,p,index,playerNationIndex): preferencePrint('',p,index,playerNationIndex) preferencePrint(str(str(currentNation[1]) + ' chose to gamble'),p,index,playerNationIndex) preferencePrint('---------------------',p,index,playerNationIndex) amount = nextMove[1] # the amount chosen to gamble originalFinanceScore = currentNation[0]['Finance']['wealth'] + amount winnings = random.randint((round(0.3*amount)), round(2*amount)) NATION_ARRAY[index][0]['Finance']['wealth'] = NATION_ARRAY[index][0]['Finance']['wealth'] + winnings difference = NATION_ARRAY[index][0]['Finance']['wealth'] - originalFinanceScore if difference > 0: preferencePrint(str(str(currentNation[1]) + ' gained +' + str(difference)),p,index,playerNationIndex) elif difference < 0: preferencePrint(str(str(currentNation[1]) + ' lost ' + str(difference)),p,index,playerNationIndex) else: preferencePrint(str(str(currentNation[1]) + ' broke even ' + str(difference)),p,index,playerNationIndex) preferencePrint(str('Gambled : ' + str(amount)),p,index,playerNationIndex) preferencePrint(str('Winnings : ' + str(winnings)),p,index,playerNationIndex) preferencePrint(str('Finance credits : ' + str(NATION_ARRAY[index][0]['Finance']['wealth'] )),p,index,playerNationIndex) return(NATION_ARRAY)
def investCountry(nextMove,NATION_ARRAY,currentNation,PRICE_TRACKER,p,index,playerNationIndex,nextMoveIndex): pending = nextMove[0] job = nextMove[1] NationChoice = nextMove[2] spendAmount = nextMove[3] nationsOriginalWealth = nextMove[4] wait = nextMove[5] moveIndex = nextMoveIndex # Get position in country array myNation = currentNation[1] thereNation = NATION_ARRAY[NationChoice][1] original = currentNation[0]['Finance']['wealth'] originalFriendshipAB = NATION_ARRAY[index][0]['Friendship'][thereNation]['level'] originalFrienshipBA = NATION_ARRAY[NationChoice][0]['Friendship'][myNation]['level'] # IF NOT YET READY if wait > 0: wait = wait -1 preferencePrint(str(str(currentNation[1]) + ' chose to Invest in ' + str(NATION_ARRAY[NationChoice][1])),p,index,playerNationIndex) preferencePrint('------------------',p,index,playerNationIndex) preferencePrint(str('Time Remaining : ' + str(wait)),p,index,playerNationIndex) nextMove = ['pending',job,NationChoice,spendAmount,nationsOriginalWealth,wait] NATION_ARRAY[index][0]['Nextmoves'][moveIndex] = nextMove if wait < 1: currentWealth = NATION_ARRAY[NationChoice][0]['Finance']['wealth'] wealthDiff = currentWealth - nationsOriginalWealth myOriginalCredits = currentNation[0]['Finance']['wealth'] if wealthDiff > 0: bonus = round(wealthDiff * 0.2) + round(wealthDiff * 0.05 * spendAmount/100) + (spendAmount * 1.5) bonus = round(bonus) #print('982348937982348937982348937982348937982348937982348937 WEALTH DIFF' + str(wealthDiff)) NATION_ARRAY[index][0]['Finance']['wealth'] = round(NATION_ARRAY[index][0]['Finance']['wealth'] + bonus) preferencePrint(str(str(currentNation[1]) + ' made a profit of $' + str(bonus)),p,index,playerNationIndex) if wealthDiff < 0: loss = 0.8 * spendAmount NATION_ARRAY[index][0]['Finance']['wealth'] = round(NATION_ARRAY[index][0]['Finance']['wealth'] + loss) preferencePrint(str(str(currentNation[1]) + ' made a loss, but recouped $' + str(loss)),p,index,playerNationIndex) if wealthDiff == 0: token = round(nationsOriginalWealth + (nationsOriginalWealth * (random.randint(1,10)/100))) token = round(token) NATION_ARRAY[index][0]['Finance']['wealth'] = round(NATION_ARRAY[index][0]['Finance']['wealth'] + token + spendAmount) preferencePrint(str(str(currentNation[1]) + ' made no profit, but gained token interest of $' + str(token)),p,index,playerNationIndex) # BOOST FRIENDSHIP NATION_ARRAY[index][0]['Friendship'][thereNation]['level'] = NATION_ARRAY[index][0]['Friendship'][thereNation]['level'] + random.randint(1,18) NATION_ARRAY[NationChoice][0]['Friendship'][myNation]['level'] = NATION_ARRAY[NationChoice][0]['Friendship'][myNation]['level'] + random.randint(1,18) preferencePrint(str(str(thereNation) + ' greatly appreciates the investment from ' + str(myNation)),p,index,playerNationIndex) preferencePrint(str('New friendship between ' + str(thereNation) + ' and ' + str(myNation) + ' has increased from ' + str(originalFriendshipAB) + ' to ' + str(NATION_ARRAY[index][0]['Friendship'][thereNation]['level'])),p,index,playerNationIndex) preferencePrint(str('New friendship between ' + str(myNation) + ' and ' + str(thereNation) + ' has increased from ' + str(originalFrienshipBA) + ' to ' + str(NATION_ARRAY[NationChoice][0]['Friendship'][myNation]['level'])),p,index,playerNationIndex) preferencePrint(str('Credits changed from $' + str(original) + ' to $' + str(currentNation[0]['Finance']['wealth'])),p,index,playerNationIndex) NATION_ARRAY[index][0]['Nextmoves'][moveIndex] = [] return(NATION_ARRAY)
def action(index, ARRAY_DICT, currentNation, p, playerNationIndex): NATION_ARRAY = ARRAY_DICT['NATION_ARRAY'] PRICE_TRACKER = ARRAY_DICT['PRICE_TRACKER'] WAR_BRIEFING = ARRAY_DICT['WAR_BRIEFING'] TECH_MAP = ARRAY_DICT['TECH_MAP'] if 'sabotaged' in currentNation[0]['Nextmoves']: preferencePrint( (str(currentNation[1]) + ' sabotaged, skipping round.'), p, index, playerNationIndex) currentNation[0]['Nextmoves'] = [] return (NATION_ARRAY, PRICE_TRACKER) # PROCESS PASS nextMoveIndex = 0 for nextMove in currentNation[0]['Nextmoves']: preferencePrint(str(''), p, index, playerNationIndex) # REMEMBER TO UPDATE NATION ARRAY (NOT CURRENT NATION) if 'pass' in nextMove: preferencePrint(str(str(currentNation[1]) + ' chose to pass'), p, index, playerNationIndex) if 'gamble' in nextMove: NATION_ARRAY = financeFunction.gambleAction( nextMove, NATION_ARRAY, currentNation, p, index, playerNationIndex) if 'buy' in nextMove: NATION_ARRAY, PRICE_TRACKER = financeFunction.buyAction( nextMove, NATION_ARRAY, currentNation, PRICE_TRACKER, p, index, playerNationIndex) if 'sell' in nextMove: NATION_ARRAY, PRICE_TRACKER = financeFunction.sellAction( nextMove, NATION_ARRAY, currentNation, PRICE_TRACKER, p, index, playerNationIndex) if 'investResource' in nextMove: NATION_ARRAY = financeFunction.investResource( nextMove, NATION_ARRAY, currentNation, PRICE_TRACKER, p, index, playerNationIndex, nextMoveIndex) if 'investCountry' in nextMove: #print('current nation' + str(currentNation[1])) NATION_ARRAY = financeFunction.investCountry( nextMove, NATION_ARRAY, currentNation, PRICE_TRACKER, p, index, playerNationIndex, nextMoveIndex) if 'drill' in nextMove: NATION_ARRAY = warFunction.drill(nextMove, NATION_ARRAY, currentNation, p, index, playerNationIndex) # Even if prices change, you get it for the order you placed if 'WeaponsBuild' in nextMove: NATION_ARRAY = warFunction.build(nextMove, NATION_ARRAY, currentNation, p, index, playerNationIndex, nextMoveIndex) if 'WeaponsScrap' in nextMove: NATION_ARRAY = warFunction.scrap(nextMove, NATION_ARRAY, currentNation, p, index, playerNationIndex) if 'espionage' in nextMove: NATION_ARRAY = warFunction.espionage(nextMove, NATION_ARRAY, currentNation, p, index, playerNationIndex) if 'research' in nextMove: NATION_ARRAY = scienceFunction.processResearch( nextMove, NATION_ARRAY, TECH_MAP, currentNation, p, index, playerNationIndex, nextMoveIndex) if 'gainResearch' in nextMove: NATION_ARRAY = scienceFunction.gainResearch( nextMove, NATION_ARRAY, TECH_MAP, currentNation, p, index, playerNationIndex, nextMoveIndex) if 'advanceEra' in nextMove: NATION_ARRAY = scienceFunction.advanceEra(nextMove, NATION_ARRAY, TECH_MAP, WAR_BRIEFING, currentNation, p, index, playerNationIndex, nextMoveIndex) nextMoveIndex = nextMoveIndex + 1 return (NATION_ARRAY, PRICE_TRACKER)