#!/usr/bin/ruby -w def suma_cifra_numero(cifra) total = 0 while cifra != 0 do digito = cifra - (cifra / 10) * 10 total += digito cifra /= 10 end return total end numero = 2012 puts "#{numero} = #{suma_cifra_numero(numero)}"
require 'net/http' require 'uri' require 'json' uri = URI.parse("https://iota.bitfinex.com:80") request = Net::HTTP::Post.new(uri) request.content_type = "application/json" request.body = JSON.dump({ "command" => "getBalances", "addresses" => [ "PHCCXKSDVE9MCVAIPPJBDMLWODELAAWCSGPEVIUZKTXEGJYTOPNUPGVKXKBOXOK9DSCGFMXYWBLKCVXUDMWNMUKK9B", "D9VMV9DBPIDBOJZSZYTDWKKWRHMBUZSCWFWDBADGXVWZPHWQUABSIHPFHRSKUNXIIXOTGNIWNKFWEVE9WJYCN9HNYW", "LJMZFOGOYITCHEDFPTINAHXL9S9KFMNFBTRUFFWMKBWAPFHZXWCJOQBHPTWZHEQDU9AGQLDFSNKLTIHXZM9VNDEBUX", "EAYKKXTMRTLJUXFMYA9OKEOXWKLOOWZEGWBSYXOGQXFDQXHBOCNFRYUCR9CBZDWMUFREOMCYCPEAOEYWBMQBNXMUXX", "FVBLZRWAJD9GLLEINPKILRGUP9MOSKVESVAGNPHIVSPKWCWUEYIBNGZEAIKSQGNHUDVPGUNWYCODTWDKCZDANWQNEZ", "XSW9RMCZXHBXATOQBNCHTATTUXBPVTN9EWANABCURYZLWKRW9ZLYLSWYTCRYBDKTIMSBSUKJQJJKHYXAXGQY9LJFYZ", "TNOABPBQJUBCEIRLNMXOJXAH9HTNUXBZXYBQQVSCCIXXWJLRMRDWSKBCK9WSAIBKHOSAAOJTGJMCPQANWQAWMW9HLA", "EQMEFFOPFYMJWHKREBBJGBPFQWSIQVDVWURFGYXVXKZUYLGSTEJHRWWFFHLEFONRNQZOHZQPLNXTBPBBWWZIZUFDJY", "KGOKNOKZWYRIFOIYBGDDQ9CVGGGOLPZKZJEMJXETSZEYZLJWCUKPRECHLJAEMIENDFJAISUYGOSRLJZNDNORGZCLAY", "J9OXFQNG9GATOWXCZYNKIEDURLTRYMOMQUQUIZTOOMTKTMQYWFBRX9PQWPAAKQHQNTWRMD9PVAUSQFRFCKFWASSSAC", "B9OCUSJS9UD9QVMDMWGQGRFRHCVINSJGAAFJEXZVTRSJDTXCFVUABRLKLCVBYJTEPJNQLZLLLOWYKEJLZYHMRZTDVY", "XQTIWBFRLDXKQASKIFDGVXONXSWBVESJAYTFCOSJFFMY9OUJCFZQNFFSDIVNEGIBXCQPUWPPMBYGGDLFCH9BINN9UX", "ZGHIRLESELHDKCYMFTOXTIHZLOQABYZDRR9FOICHMVCFWJVBICRHFXXKTGNETNLSCAJGMKJTQPTUDAEECWNZLWPWYZ", "OSWTHMBRPVCHDOOPUEMZKNMYRLVFESLGZJPNSKG9MRRBTQSCHIGKCIDHQVHMVAHMXQYZRZPDBDPJJTHA9OZTRVMM9C", "GZ9GMSKBUFTYWCHZZRRXXHRIVBKJXBET9OMKSFTMTXDLEFSENENJZKHAUZGTKLTIVHVHXDSNLVDOKUIWZLCOB9VEUD", "QOM9ZNCUJOIVSHJFIYIPJSDKFFZMHBTUYNDRHZRDUEBKAGJPTSPPBJFZL9BCJUUSOVBXZEENTSVOSKYUDJDIMNEQKD", "WJGNFSIIPMUG9VPSSWBJYQ9VCWHGNDBJBMCGTXDHJMBQYKNIUQTGDIJPKZ9WCFEQCKRTZO99LKXEY9VSDKAOEWHNDZ" ], "threshold" => 100 }) req_options = { use_ssl: uri.scheme == "https", } response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http| http.request(request) end puts response.body
#!/usr/bin/ruby class TablaDeMul def m nums1 = [1, 2, 3, 4, 5, 6 ,7 ,8 ,9] nums2 = [1, 2, 3, 4, 5, 6 ,7 ,8 ,9] puts "_" * 20 nums1.each do |i| nums2.each do |j| puts " #{i} * #{nums1[j]} = #{nums1[i] * nums2[j]}" end end puts "_" * 20 end end mul1 = TablaDeMul.new mul1.m
# Define players' names players = { blue: { name: 'Maury', qi: 135 }, master: { name: 'Bodeux', qi: 97 } } # Load players. puts "Génial, #{players[:blue][:name]} vient de se faire acheter par #{players[:master][:name]} !" puts "" # Generate actions. actions = [ { desc: "vient de faire une fellation au", qiRemove: 3 }, { desc: "vient de faire une GET au", qiRemove: 2 }, { desc: "vient de se prendre une gifle du", qiRemove: 1 }, { desc: "doit enfoncer un concombre dans son anus pour le", qiRemove: 1 } ] # Generate sublime. sublime = ['sublime', 'génial', 'trop cool', 'incroyable', 'magnifique'] # Game ON. puts "Que le jeu commence !" while players[:blue][:qi] >= players[:master][:qi] random = Random.rand(0..actions.length-1) players[:blue][:qi] -= actions[random][:qiRemove] puts "#{players[:blue][:name]} #{actions[random][:desc]} #{sublime[Random.rand(0..sublime.length-1)]} #{players[:master][:name]} (son QI est de #{players[:blue][:qi]})" end puts "Enfin ce gros con de bleu est inférieur :D !"
# Define players' names players = { blue: { name: 'Pablo', qi: 120 }, master: { name: 'Bodeux', qi: 100 } } # Load players. puts "Génial, #{players[:blue][:name]} vient de se faire acheter par #{players[:master][:name]} !" puts "" # Generate actions. actions = [ { desc: "vient de faire une fellation au", qiRemove: 3 }, { desc: "vient de faire une GET au", qiRemove: 2 }, { desc: "vient de se prendre une gifle du", qiRemove: 1 }, { desc: "doit enfoncer un concombre dans son anus pour le", qiRemove: 1 } ] # Generate sublime. sublime = ['sublime', 'génial', 'trop cool', 'incroyable', 'magnifique'] # Game ON. puts "Que le jeu commence !" while players[:blue][:qi] >= players[:master][:qi] random = Random.rand(0...4) players[:blue][:qi] -= actions[random][:qiRemove] puts "#{players[:blue][:name]} #{actions[random][:desc]} #{sublime[Random.rand(0...5)]} #{players[:master][:name]} (son QI est de #{players[:blue][:qi]})" end puts "Enfin ce gros con de bleu est inférieur :D !"
## BASIC TEST # REMINDER Items need to be unique or Ruby will overwrite them #ItemID /F / S / W / Value / Title $tradershand = { } #ItemID /F / S / W / Value / Title $yourhand = { } $discardpile = { } $dropholdingbay = { } $consumeholdingbay = { } $dumpholdingbay = { } $cancelitemholdingbay = { } # REMINDER Items need to be unique or Ruby will overwrite them $traderlisting = [$trader1inventory, $trader2inventory] $RummageMaster = { 'soda can' => [0,0,0,1,'You can\'t eat it, but you might be able to trade it.','soda can'], 'scrap metal' => [0,0,0,1,'You can\'t eat it, but you might be able to trade it.','scrap metal'], 'old wire' => [0,0,0,1,'You can\'t eat it, but you might be able to trade it.','old wire'], 'ham sandwich' => [1,0,0,1,'A ham sandwich does the job to fill the belly.','ham sandwich'], 'some coins' => [0,0,0,1,'You can\'t eat it, but you might be able to trade it.','some coins'], 'a few coins' => [0,0,0,1,'You can\'t eat it, but you might be able to trade it.','a few coins'], 'a handful of coins' => [0,0,0,2,'You can\'t eat it, but you might be able to trade it.','a handful of coins'], 'two coins' => [0,0,0,1,'You can\'t eat it, but you might be able to trade it.','two coins'], 'old coins' => [0,0,0,1,'You can\'t eat it, but you might be able to trade it.','old coins'], 'a shiny coin' => [0,0,0,1,'You can\'t eat it, but you might be able to trade it.','a shiny coin'], 'a greenish coin' => [0,0,0,1,'You can\'t eat it, but you might be able to trade it.','a greenish coin'], 'cardboard' => [0,0,2,1,'This sheet of cardboard can be used as a little shelter to keep the cold at bay.','cardboard'], 'half a wine spritzer' => [0,1,0,1,'Take away the stress of today with a wine spritzer.','half a wine spritzer'] } # REMINDER Items need to be unique or Ruby will overwrite them # KEY PLAYER INVENTORY $p1inventory = { #ItemID /F / S / W / Value / Title 'A ten dollar note' => [0,0,0,10,'It\'s not much, but hopefully it will come in handy.', 'A ten dollar note'], 'An apple' => [1,0,0,10,'A crunchy and delicious Granny Smith apple.', 'An apple'] } # REMINDER Items need to be unique or Ruby will overwrite them # TRADER INVENTORY $trader1inventory = { #ItemID /F / S / W / Value / Title 'medicine' => [0,0,3,3,'Feeling sick or cold? This medicine will give you a boost to get you feeling better - but it\'ll cost you.','medicine'], 'necklace' => [0,0,0,2,'You can\'t eat it, but you might be able to trade it.','necklace'], 'packet of chips' => [1,0,0,1,'Barbeque flavoured chips. The best.','packet of chips'], 'pie' => [1,0,0,1,'There\'s no sauce, but a meat pie fills the hole.','pie'], 'book' => [0,3,0,1,'Want to escape into another life for a little while? A book is a comforting escape that will make you feel better.','book'], 'blanket' => [0,0,3,2,'This thin blanket will keep the cold off you, but is too heavy to carry for long.','blanket'], 'half bottle of wine' => [0,1,0,1,'The best way to feel better.','half bottle of wine'] } $trader2inventory = { #ItemID /F / S / W / Value / Title 'threadbare jumper' => [0,0,2,1,'This jumper will give you a little warmth before it disintegrates.','threadbare jumper'], 'handbag' => [0,0,0,3,'You can\'t eat it, but you might be able to trade it.','handbag'], 'slice of pizza' => [1,0,0,1,'It a bit cold, but you can\'t go wrong with pizza.','slice of pizza'], 'half a kebab' => [1,0,0,1,'Who needs a full kebab? No one.','half a kebab'], 'sack of goon' => [0,1,1,1,'Sweet goon sack, help me forget my troubles.','sack of goon'], 'magazine' => [0,1,0,1,'Sometimes some pretty pictures and little daydreaming is what you need to lift your mood.','magazine'] } # REMINDER Items need to be unique or Ruby will overwrite them $EventsMaster = { #EventName /F / S / W / Trader / Description 'You stare at the concrete, desperately hoping for something to happen. Anyone to talk to. And you realise it\'s been hours since anyone has spoken to you. Lonliness sets it.' => [0,-1,0,'notrade','You stare at the concrete, desperately hoping for something to happen. Anyone to talk to. And you realise it\'s been hours since anyone has spoken to you. Lonliness sets it.'], 'You see a woman who looks a lot like your sister. You feel a sudden pang of lonliness as you miss your sister.' => [0,-1,0,'notrade','You see a woman who looks a lot like your sister. You feel a sudden pang of lonliness as you miss your sister.'], 'A woman with a large handbag scowls at you, before yelling "Get a job, bludger!". You think about how you got here and if there was anything you could have changed. You don\'t think there was. But you hate yourself and your situation, even more.' => [0,-1,0,'notrade','A woman with a large handbag scowls at you, before yelling "Get a job, bludger!". You think about how you got here and if there was anything you could have changed. You don\'t think there was. But you hate yourself and your situation, even more.'], 'A man with a trolley stops and says he is willing to trade.' => [0,0,0,'traderhere','A man with a trolley stops and says he is willing to trade.'], 'You spot the man with the trolley across the road. He might have goods to trade.' => [0,0,0,'traderhere','You spot the man with the trolley across the road. He might have goods to trade.'], 'You think you can see the trader trolley man. Will he trade today?' => [0,0,0,'traderhere','You think you can see the trader trolley man. Will he trade today?'], 'The tarp covers his trolley, but you are sure that is the man happy to trade.' => [0,0,0,'traderhere','The tarp covers his trolley, but you are sure that is the man happy to trade.'], 'The trolley man on his way to the recycling centre says he is willing to trade.' => [0,0,0,'traderhere','The trolley man on his way to the recycling centre says he is willing to trade.'], 'The man with the trolley often just has scraps but maybe you can trade for something useful.' => [0,0,0,'traderhere','The man with the trolley often just has scraps but maybe you can trade for something useful.'], 'You find a half a kebab left by a diner at a cafe. You wolf it down.' => [1,0,0,'notrade','You find a half a kebab left by a diner at a cafe. You wolf it down.'], 'At a food court, you see someone only ate a few bites of their curry before leaving it. You sit down and eat and eat and eat.' => [2,0,0,'notrade','At a food court, you see someone only ate a few bites of their curry before leaving it. You sit down and eat and eat and eat.'], 'Some teenagers give you half a bag of chips. The salt tastes amazing.' => [1,0,0,'notrade','Some teenagers give you half a bag of chips. The salt tastes amazing.'], 'Half a hamburger sits in it\'s takeout container. Time to eat.' => [1,0,0,'notrade','Half a hamburger sits in it\'s takeout container. Time to eat.'], 'You find a sack of goon in the bin. \'Cheers\', you whisper as you suck the sickly sweet wine. You feel a lot better.' => [0,1,1,'notrade','You find a sack of goon in the bin. \'Cheers\', you whisper as you suck the sickly sweet wine. You feel a lot better.'], 'You meet a new friend, and you are sharing your experiences on the street. Someone gives you a sandwich, but his gaze shows that he hasn\'t eaten in a long time. You give him the sandwich.' => [-1,0,0,'notrade','You meet a new friend, and you are sharing your experiences on the street. Someone gives you a sandwich, but his gaze shows that he hasn\'t eaten in a long time. You give him the sandwich.'], 'You get given some hot chips by a stranger, but as you walk past a man crying on the street, you see his situation is worse than yours and you give him the food.' => [-1,0,0,'notrade','You get given some hot chips by a stranger, but as you walk past a man crying on the street, you see his situation is worse than yours and you give him the food.'], 'A local officeworker buys two sandwiches for lunch, and gives you one. Oh, fresh lettuce!' => [1,0,0,'notrade','A local officeworker buys two sandwiches for lunch, and gives you one. Oh, fresh lettuce!'], 'A man in a suit offers to buy you a bagel. He even gets cream cheese.' => [1,0,0,'notrade','A man in a suit offers to buy you a bagel. He even gets cream cheese.'], 'You find half of a bottle of wine near the trash. You take a sip. Screw it. It keeps out the cold and makes today feel a little less hopeless.' => [0,2,1,'notrade','You find half of a bottle of wine near the trash. You take a sip. Screw it. It keeps out the cold and makes today feel a little less hopeless.'], 'No one has said anything to you for hours. No one looks at you. Grief for your old life is almost overwhelming.' => [0,-1,0,'notrade','No one has said anything to you for hours. No one looks at you. Grief for your old life is almost overwhelming.'], 'You don\'t know what time it is. You wish you had something to do. Waiting for the day to end isn\'t enough.' => [0,-1,0,'notrade','You don\'t know what time it is. You wish you had something to do. Waiting for the day to end isn\'t enough.'], 'You talk to a local market holder, hoping you can get some work loading their stock. They look at your dirty fingernails and say that they are not looking for anyone.' => [0,-1,0,'notrade','You talk to a local market holder, hoping you can get some work loading their stock. They look at your dirty fingernails and say that they are not looking for anyone.'], 'You see a burger in the trash, but you realise it\'s been covered in beer. It\'s not salvagable.' => [0,0,0,'notrade','You see a burger in the trash, but you realise it\'s been covered in beer. It\'s not salvagable.'], 'A woman offers you buy you food in the grocery store - but when she left she seemed to have forgotten all about it. Fuck.' => [0,0,0,'notrade','A woman offers you buy you food in the grocery store - but when she left she seemed to have forgotten all about it. Fuck.'], 'You ask the local bookstore if they need help moving books. You can carry things and you work hard. They don\'t.' => [0,-1,0,'You ask the local bookstore if they need help moving books. You can carry things and you work hard. They don\'t.'], 'You see the local cafe has a job in the kitchen. You ask if it\'s still available. \'Mate, we don\'t want to give anyone a disease!\' the manager scowls.' => [0,-1,0,'notrade','You see the local cafe has a job in the kitchen. You ask if it\'s still available. \'Mate, we don\'t want to give anyone a disease!\' the manager scowls.'], 'A passerby stops for a chat for fifteen minutes. They share a story they had of a tough time and give you some encouragement. They said \'see you later\'. Maybe you\'ve made a friend? You hope so.' => [0,1,0,'notrade','A passerby stops for a chat for fifteen minutes. They share a story they had of a tough time and give you some encouragement. They said \'see you later\'. Maybe you\'ve made a friend? You hope so.'], 'People always look in another direction when they see you. They don\'t want to feel the guilt of not being able to give. Sometimes the giving doesn\'t matter, just the connection. A woman nodded and said \'hi\'. Someone seeing you can make all the difference.' => [0,1,0,'notrade','People always look in another direction when they see you. They don\'t want to feel the guilt of not being able to give. Sometimes the giving doesn\'t matter, just the connection. A woman nodded and said \'hi\'. Someone seeing you can make all the difference.'], 'The man who works at the grocery store stopped for a chat on his smoke break. He chatted about the shift in weather and the elections coming up. It was nice.' => [0,1,0,'notrade','The man who works at the grocery store stopped for a chat on his smoke break. He chatted about the shift in weather and the elections coming up. It was nice.'], 'A man named Dave joins you for a few hours, sharing a smoke. He was homeless too, but he is going to visit his kids this weekend. He couldn\'t wait. It was good to hear that despite this situation, there were moments of hope.' => [0,1,0,'notrade','A man named Dave joins you for a few hours, sharing a smoke. He was homeless too, but he is going to visit his kids this weekend. He couldn\'t wait. It was good to hear that despite this situation, there were moments of hope.'], 'You find some newspaper and find that if you wrap it around yourself, you can keep out some of the cold. It warms you up, but it\'s humiliating.' => [0,0,1,'notrade','You find some newspaper and find that if you wrap it around yourself, you can keep out some of the cold. It warms you up, but it\'s humiliating.'], 'You get caught in the rain and all your clothes are wet. Fuck. You\'re freezing.' => [0,0,-2,'notrade','You get caught in the rain and all your clothes are wet. Fuck. You\'re freezing.'], 'You find someone has left a jumper at a bus stop. It is too small but you can use it as a scarf.' => [0,0,1,'notrade','You find someone has left a jumper at a bus stop. It is too small but you can use it as a scarf.'], 'You pass a Vinnies clothing bin and dig around and find a scarf. It\'s hypercoloured from the 90s. It might brighten your day.' => [0,0,1,'notrade','You pass a Vinnies clothing bin and dig around and find a scarf. It\'s hypercoloured from the 90s. It might brighten your day.'], 'The jumper you are in has become threadbare and the cold seeps in.' => [0,0,-1,'notrade','The jumper you are in has become threadbare and the cold seeps in.'], 'You are cold. Really cold. You start circling the block to try to warm up. It helps a little, but you worry about leaving your stuff.' => [0,0,1,'notrade','You are cold. Really cold. You start circling the block to try to warm up. It helps a little, but you worry about leaving your stuff.'], 'There is a sudden thunderstorm today and the temperature drops. It is too fucking cold.' => [0,0,1,'notrade','There is a sudden thunderstorm today and the temperature drops. It is too fucking cold.'], 'The biting wind from the south chills the air and you cannot get warm.' => [0,0,-1,'notrade','The biting wind from the south chills the air and you cannot get warm.'], 'You sit for an hour and you feel dirty. All of a sudden, the grime, sweat exhaustion exudes from your skin and you would like nothing more than to have a shower to wash away this day. But the only options are the sink in a shopping centre, or the local pool, which you cannot afford entry to. Try to keep it together for another day.' => [0,-1,0,'notrade','You sit for an hour and you feel dirty. All of a sudden, the grime, sweat exhaustion exudes from your skin and you would like nothing more than to have a shower to wash away this day. But the only options are the sink in a shopping centre, or the local pool, which you cannot afford entry to. Try to keep it together for another day.'] } $NightEventsMaster = { #EventName /F / S / W / Trader / Description 'The couple sleeping near you begin fighting overnight. You can\'t sleep and you are afraid.' => [0,-1,0,'notrade','The couple sleeping near you begin fighting overnight. You can\'t sleep and you are afraid.'], 'At night, some teenagers coming off a pub crawl find you. They are rowdy, so you pretend to be asleep. One of them urinates right next to you and you try not to gag.' => [0,-1,0,'notrade','At night, some teenagers coming off a pub crawl find you. They are rowdy, so you pretend to be asleep. One of them urinates right next to you and you try not to gag.'], 'You mind is going over every moment of the last week before you lost your job. You cannot sleep.' => [0,0,0,'You mind is going over every moment of the last week before you lost your job. You cannot sleep.'], 'It is so cold. You struggle to sleep.' => [0,0,0,'It is so cold. You struggle to sleep.'], 'Some people sleeping nearby look like they will rob you if you fall asleep. You try to stay awake.' => [0,-1,0,'Some people sleeping nearby look like they will rob you if you fall asleep. You try to stay awake.'], 'You sleep for a few hours fitfully.' => [0,1,0,'You sleep for a few hours fitfully.'], 'You grab some sleep, and you feel better.' => [0,1,0,'You grab some sleep, and you feel better.'], 'You hear an alarm go off in the building nearby. You are afraid police will arrest you if they find you.' => [0,-1,0,'You hear an alarm go off in the building nearby. You are afraid police will arrest you if they find you.'], 'You sleep fitfully, but realise that it was rained over your stuff overnight and everything is saturated.' => [0,0,-1,'notrade','You sleep fitfully, but realise that it was rained over your stuff overnight and everything is saturated.'], 'You rest, dreaming about your bed. You prefend you are back in your old life for a few moments.' => [0,1,0,'notrade','You rest, dreaming about your bed. You prefend you are back in your old life for a few moments.'], 'Security staff come from somewhere and glower at you. You don\'t want to sleep.' => [0,-1,0,'notrade','Security staff come from somewhere and glower at you. You don\'t want to sleep.'], 'How long has it been since you slept? You\'re not sure.' => [0,0,0,'notrade','How long has it been since you slept? You\'re not sure.'], 'You sleep, without dreams. Thank god.' => [0,0,0,'notrade','You sleep, without dreams. Thank god.'], 'There is a loud screech and the sound of people screaming nearly. You are jolted awake.' => [0,-1,0,'notrade','There is a loud screech and the sound of people screaming nearly. You are jolted awake.'], 'You sleep and when you wake, someone has left a warm coffee for you. Perhaps someone is looking down on you, afterall.' => [1,0,1,'notrade','You sleep and when you wake, someone has left a warm coffee for you. Perhaps someone is looking down on you, afterall.'], 'You dream about food. When you wake, a kind stranger has left some hot chips, which warms you up.' => [1,0,1,'notrade','You dream about food. When you wake, a kind stranger has left some hot chips, which warms you up.'] } # KEY PLAYER STATS $p1stats = { 'food' => 5, 'safety' => 5, 'warmth' => 5, } $LocationsMaster = { #Location /F / S / W / Events / Rummage / trader / Desription 'Supermarket' => [-1,0,-2,3,3,'traderhere','There is always someone willing to trade at the supermarket, but it is cold.'], 'Bus Shelter' => [-1,-1,-2,3,3,'notrade','The bus shelter is cold and feels sketchy, but there is often a lot to rummage for.'], 'Park' => [-1,0,-1,3,2,'notrade','Well-lit in the daytime, the park is safe, but cool. There is not much to find in the bins.'], 'Flinders Street Station' => [-1,+1,0,5,2,'notrade','The train station is safe and warm while the trains run, but it is very busy so a lot happens.'] } $NightLocationsMaster = { #Location /F / S / W / Events / Rummage / trader / Desription 'Building Site' => [-1,0,0,3,2,'notrade','The building site is safe at night and keeps the cold at bay, but climbing the fence to get in leaves you feeling hungry.'], 'Crisis Accom' => [1,-2,1,4,3,'notrade','You get given food and it is warm, but the fighting at the Crisis Accomodation makes it hard to sleep.'], 'Park' => [0,-1,-2,3,4,'notrade','It is cold at night and becomes a hangout for drunk teens so you feel unsafe.'], 'Flinders Street Station' => [0,1,-3,4,4,'notrade','The train station is still busy at night, but when the sun sets it is freezing. You feel safe there with the constant security, though.'] } # KEY HEALTH STATS ABOVE # ------------------------------------------------------------- ## STORY BELOW def p1statusreportmorning #STATS LIBRARY currentfood = $p1stats['food'] currentsafety = $p1stats['safety'] currentwarmth = $p1stats['warmth'] # ____________________________________ # STATS rundown if currentfood <= 1 puts "(!!!) You are starving! You will be injured if you don't eat enough today." elsif currentfood >= 2 && currentfood <= 3 puts "(!) You are exceptionally hungry. You must find food today." elsif currentfood >= 4 && currentfood <= 5 puts "You are hungry. You should find food." elsif currentfood >= 6 puts "You are not hungry right now." else puts "Ouch." end if currentsafety <= 1 puts "(!!!) You can't go on. You will be injured if you don't find something to hake you feel better today." elsif currentsafety >= 2 && currentsafety <= 3 puts "(!) You are depressed and feeling alone. You need to find something to help you feel better." elsif currentsafety >= 4 && currentsafety <= 5 puts "You are feeling okay, but could use something to feel better." elsif currentsafety >= 6 puts "You are feeling hopeful that things might get better." else puts "Ouch." end if currentwarmth <= 1 puts "(!!!) You are sick, bleary eyed and exhausted. You will be injured if you don't get warmth or medicine today." elsif currentwarmth >= 2 && currentwarmth <= 3 puts "(!) You are freezing. You need to get warm immediately!" elsif currentwarmth >= 4 && currentwarmth <= 5 puts "You are feeling a little cold. You should try to find something to warm you up." elsif currentwarmth >= 6 && currentwarmth <= 8 puts "You are keeping the cold at bay." elsif currentwarmth >= 10 puts "You are feeling toasty." else puts "Ouch." end end def timewarp if $hotjumptag == 'morningnoms' locationselect elsif $hotjumptag == 'daytradenoms' rummagetime elsif $hotjumptag == 'afternoonnoms' gamewrap elsif $hotjumptag == 'nightnoms' nightlocselect else puts "Er..?" end end def continueplz puts "---------------------------press ENTER to proceed:" puts "> " keystroke = $stdin.gets.chomp if keystroke == "\n" else end end def prompt puts ">" end def p1emptyinventorycheck p1emptycheck = $p1inventory.empty? if p1emptycheck == true puts "(!) Your bag is empty. Type 'done' to continue" else end end # ----- QUICK REFS ABOVE # -------- THIS IS PART OF THE DUMP ITEM SERIES ------- def dumpfinalpush # puts "Move items from dumpholdingbay to RummageMaster" $RummageMaster.merge!($dumpholdingbay) $dumpholdingbay.delete_if{|k,_| k} end def showplayer1sinventory puts " ------------- " puts "These are the items in your bag:" $p1inventory.each do |itemiD, detailsofpitems| #assigned key, value puts "#{detailsofpitems[-1]}: #{detailsofpitems[-2]}" #tells which item in array to access end end def loopnewitemtodump itemtodump end def dumpemtycheck dumpemtycheck = $dumpholdingbay.empty? if dumpemtycheck == true puts "(!) You have not selected anything to dump." continueplz itemtodump else # puts "You have selected an item" end end def itemtodump puts "You've got a lot of items in your bag. Choose which ones to throw away." showplayer1sinventory puts " ------------- " dumpingthisitem = 0 puts "What do you want to dump by the road?" puts "item: Type the name of the item you want to dump done: Type 'done' if you have selected everything you want to get rid of" puts "------------------------------------------- to proceed:" prompt dumpingthisitem = $stdin.gets.chomp puts " ------------- " if $p1inventory.has_key?(dumpingthisitem) activedumpitem = $p1inventory[dumpingthisitem] taggeditem = activedumpitem[-1] puts "You want to dump #{dumpingthisitem} by the side of the road." elsif dumpingthisitem == 'done' dumpemtycheck puts "You have left these items by the side of the road. Perhaps someone else will find them useful." dumpfinalpush # exit if they do not want anything elsif dumpingthisitem == 'd' dumpemtycheck puts "You have left these items by the side of the road. Perhaps someone else will find them useful." dumpfinalpush # exit if they do not want anything elsif dumpingthisitem == 'cancel' puts "You have chosen not to dump anything." timewarp elsif dumpingthisitem == 'leave' puts "You have chosen not to dump anything." timewarp elsif dumpingthisitem == 'exit' puts "You have chosen not to dump anything." timewarp else puts "(!) What item were you wanting to dump?" loopnewitemtodump end #Find the whole key for it it be updated to Trader's hand. desireditemkey = Hash[*$p1inventory.assoc(activedumpitem[-1])] # Note: to find $taggeditem, it is in finditem # Push from Trader Inventory to TraderHand. $dumpholdingbay.update(desireditemkey) $p1inventory.delete_if{|k,_| k == taggeditem} # Shows the trader's hand.... puts "---------" # Offer to loop for more items. puts "Do you want to dump another item?" puts"y: continue dumping from bag done: dump these items" puts "------------------------------------------- to proceed:" prompt moredumpingitems = $stdin.gets.chomp if moredumpingitems == 'y' loopnewitemtodump elsif moredumpingitems == 'done' dumpemtycheck puts "You have left these items by the side of the road:" $dumpholdingbay.each do |itemiD, detailsofitemstodump| #assigned key, value puts "#{detailsofitemstodump[-1]}: #{detailsofitemstodump[-2]}" #tells which item in array to access end puts "Perhaps someone else will find them useful." dumpfinalpush continueplz elsif moredumpingitems == 'd' dumpemtycheck puts "You have left these items by the side of the road. Perhaps someone else will find them useful." dumpfinalpush elsif moredumpingitems == 'cancel' puts "You have chosen not to dump anything." elsif moredumpingitems == 'leave' puts "You have chosen not to dump anything." elsif moredumpingitems == 'exit' puts "You have chosen not to dump anything." else puts "You have chosen not to dump anything." end end # -------- THIS IS PART OF THE CONSUME ITEM SERIES ------- def consumeexitsweep #ifholdingbay has items then merge. emptybay = $consumeholdingbay.empty? if emptybay == false then $p1inventory.merge!($consumeholdingbay) $consumeholdingbay.delete_if{|k,_| k} #puts "Bay cleared" else #puts "no action" end puts "You close your bag." timewarp end def rejectinedible $p1inventory.update($desiredcitemkey) $consumeholdingbay.delete_if{|k,_| k == $taggedcitem} end def ediblecheck #puts $desiredcitemkey #puts $itemtoeat foodval = $itemtoeat[0] safetyval = $itemtoeat[1] warmthval = $itemtoeat[2] moneyval = $itemtoeat[3] #puts foodval #puts safetyval if foodval == 0 && safetyval == 0 && warmthval == 0 puts "(!) You cannot eat or wear this item. You might be able to trade it." rejectinedible continueplz loopneweatitem else #puts "This item is edible. Hooray!" consumefinalpush end end # ------------- def consumefinalpush puts "-------------" # Cycles through each item in the consumeholding bay and applies the stats to points #BEFORE STATS beforenomming = $p1stats['food'] beforesafety = $p1stats['safety'] beforewarmth = $p1stats['warmth'] # CONSUME ITEMS $consumeholdingbay.each do |itemiD, detailsofbag| #assigned key, value #puts "#{detailsofbag[-1]}" #tells which item in array to access #puts "You pull #{detailsofbag[-1]} from your bag." $p1stats['food'] += detailsofbag[0] $p1stats['safety'] += detailsofbag[1] $p1stats['warmth'] += detailsofbag[2] #AFTER NOMMING STATS afternomming = $p1stats['food'] aftersafety = $p1stats['safety'] afterwarmth = $p1stats['warmth'] if beforenomming < afternomming #puts "You are less hungry now." puts "You pick #{detailsofbag[-1]} from your bag and eat it. You aren't as hungry now." else #puts "No change in state" end if beforesafety < aftersafety #puts "You are feeling less anxious now." puts "You grab #{detailsofbag[-1]} from your bag and use it. You feel happier." else #puts "No change in state" end if beforewarmth < afterwarmth #puts "You are a little bit warmer now." puts "You feel #{detailsofbag[-1]} wrap around you and you feel warmer." else #puts "No change in state" end end puts "You have a bit more room in your bag now." $consumeholdingbay.delete_if{|k,_| k} # deletes items from holding bay once consumed eatmorecheck end def eatmorecheck continueplz noitemstoconsume puts "Do you want to consume more?" loopneweatitem #exit(0) end def loopneweatitem noitemstoconsume consumeitem end def eatemptycheck eatemptycheck = $consumeholdingbay.empty? if eatemptycheck == true puts "(!) You have not selected anything to use or eat." consumeitem else # puts "You have selected an item" end end def noitemstoconsume cemptycheckitems = $p1inventory.empty? if cemptycheckitems == true puts "Your bag is empty." consumeexitsweep else end end # -- CONSUME ITEM def consumeitem noitemstoconsume showplayer1sinventory puts " ------------- " puts "What do you want to select?" puts "item: Type the name of one item you want to use or eat" puts "cancel: close bag." puts "------------------------------------------- to proceed:" puts " >" eatthisitem = $stdin.gets.chomp #puts " ------------- " if $p1inventory.has_key?(eatthisitem) $itemtoeat = $p1inventory[eatthisitem] $taggedcitem = $itemtoeat[-1] #puts "You have selected: #{eatthisitem}" #Moveitemtoholdingbay $desiredcitemkey = Hash[*$p1inventory.assoc($itemtoeat[-1])] $consumeholdingbay.update($desiredcitemkey) $p1inventory.delete_if{|k,_| k == $taggedcitem} #Push to checks and consume. eatemptycheck ediblecheck consumefinalpush elsif eatthisitem == 'cancel' consumeexitsweep elsif eatthisitem == 'leave' consumeexitsweep elsif eatthisitem == 'close' consumeexitsweep elsif eatthisitem == 'exit' consumeexitsweep else puts "(!) Typo detected. What was it wanted to use or eat?" loopneweatitem end end def consumeitemintro puts " ------------- " puts "You've got some items in your bag." puts "You can eat the food to reduce your hunger, or put on the clothing for warmth." puts "Using items will clear up space in your bag." consumeitem end # ---------------- OPEN BAG SERIES ------ def openbag puts "Do you want to use any of the items in your bag?" puts "y: yes, open your bag | or ENTER to skip." puts "----------------------------- type your response to proceed" puts "> " getbagitemsdecision = $stdin.gets.chomp if getbagitemsdecision == "y" consumeitemintro elsif getbagitemsdecision == "yes" consumeitemintro elsif getbagitemsdecision == "n" puts "You do not open your bag." elsif getbagitemsdecision == "cancel" timewarp elsif getbagitemsdecision == "exit" timewarp else end end def injuryreport if $dayhealthpre < $dayhealthpost puts "(!) You have been injured badly from today's events!" else end end def deathpointsstatus if $deathpoints != 0 puts "You have sustained #{$deathpoints} injuries." else #puts "Ouch." end end def p1statusreport #STATS LIBRARY currentfood = $p1stats['food'] currentsafety = $p1stats['safety'] currentwarmth = $p1stats['warmth'] # ____________________________________ # STATS rundown if currentfood <= 1 puts "(!!!) You are starving! Finding food is essential." $deathpoints += 1 $dayhealthpost += 1 elsif currentfood >= 2 && currentfood <= 3 puts "(!) You are exceptionally hungry. You must find food." elsif currentfood >= 4 && currentfood <= 5 puts "You are hungry. You must find food." elsif currentfood >= 6 puts "You are not hungry right now." else puts "Ouch." end if currentsafety <= 1 puts "(!!!) You don't want to wake up tomorrow. Finding something to make you happier is essential." $deathpoints += 1 $dayhealthpost += 1 elsif currentsafety >= 2 && currentsafety <= 3 puts "(!) You are depressed and feeling alone. You need to find something to help you feel better." elsif currentsafety >= 4 && currentsafety <= 5 puts "You are feeling okay, but could use something to feel better." elsif currentsafety >= 6 puts "You are feeling hopeful that things might get better." else puts "Ouch." end if currentwarmth <= 1 puts "(!!!) You have become ill from the cold. Finding warmth or medicine should be your priority." $deathpoints += 1 $dayhealthpost += 1 elsif currentwarmth >= 2 && currentwarmth <= 3 puts "(!) You are freezing. You need to get warm immediately!" elsif currentwarmth >= 4 && currentwarmth <= 5 puts "You are feeling a little cold. You should try to find something to warm you up." elsif currentwarmth >= 6 && currentwarmth <= 8 puts "You are keeping the cold at bay." elsif currentwarmth >= 10 puts "You are feeling toasty." else puts "Ouch." end end def daycountcheck #Death Points if $deathpoints >= 5 puts "(!) You stagger over and fall to the ground and don't get up. People step around you." exit(0) elsif $deathpoints >= 3 && $deathpoints <= 4 puts "(!) Your health is declining rapidly. At 5 injuries, you might not make it. Current injuries: #{$deathpoints}" else puts " " end if $daycount == 10 puts "(!) Your sister has arrived. Her car is old and bunny hops down the road. She tries to smile when you get in the car. You are hopeful that this time things will be better." exit(0) elsif $daycount == 9 puts " (!) You called your sister again. She is on her way and will be here in a few days." elsif $daycount == 7 puts " (!) You call your sister. She isn't happy to hear from you. But she will let you stay for a few weeks so you can try to get back on your feet. She will pick you up in a few days." elsif $daycount == 1 puts " (!) You survived your first day. Just need to find food, stay warm and keep thinking positively." elsif $daycount == 2 puts " (!) Two days on the street. Just need to keep going. Food. Warmth. Positive thinking." elsif $daycount == 3 puts " (!) Three days on the street. It's getting harder." elsif $daycount == 5 puts " (!) It's not even been a week. How do people do this for years?" else puts " " end $daycount += 1 end # _______________________ # --- SELECT NIGHT LOCATION def nightlocationloop nightlocselect end def nightlocselect $activenightlocation = 0 puts "You need to find somewhere to stay the night." puts "Where do you want to stay the night?" puts " " puts "Your options are:" $NightLocationsMaster.each do |itemiD, detailsofpitems| #assigned key, value puts "#{itemiD} - #{detailsofpitems[-1]}" #tells which item in array to access puts "---------" end puts "------------------------------------type location to proceed:" puts ">" getnightlocation = $stdin.gets.chomp if getnightlocation == "Park" then $activenightlocation = $NightLocationsMaster["Park"] locationstartnight elsif getnightlocation == "Crisis Accom" $activenightlocation = $NightLocationsMaster["Crisis Accom"] locationstartnight elsif getnightlocation == "Building Site" $activenightlocation = $NightLocationsMaster["Building Site"] locationstartnight elsif getnightlocation == "Flinders Street Station" $activenightlocation = $NightLocationsMaster["Flinders Street Station"] locationstartnight elsif getnightlocation == "cancel" exit(0) elsif getnightlocation == "exit" exit(0) else puts "(!) Typo detected. Please try again." nightlocationloop end end #LOCATION AT NIGHT NIGHT ----------------------- def locationstartnight #puts 'We have arrived at your location' # APPLIES LOCATION STATS puts $activenightlocation[-1] #locationdescription continueplz $p1stats['food'] += $activenightlocation[0] $p1stats['safety'] += $activenightlocation[1] $p1stats['warmth'] += $activenightlocation[2] #EVENTS AT LOCATION #How many Events happen in the park loceventsnight = $activenightlocation[3] # Loop to display te number of park events venuestartnight = 0 while venuestartnight < loceventsnight # puts "Triggering event cycle" $newnightevent = $NightEventsMaster[$NightEventsMaster.keys.sample] #Lists the event that happened puts $newnightevent[-1] #applies event stats to P1 $p1stats['food'] += $newnightevent[0] $p1stats['safety'] += $newnightevent[1] $p1stats['warmth'] += $newnightevent[2] #trigger to loop until met venue events venuestartnight += 1 continueplz end # END OF NIGHT EVENT CYCLE puts "The sky lightens in the east." continueplz end # --------------------------RUMMAG TIME WITHIN-------- def rummagetime puts "It's late afternoon. You had better think about moving on. But first, you want to see if there is anything edible in the bins." bagcheck # heads to bag check def and then returns to check if you have room to rmmage puts "You begin to search the bins." continueplz # See how much loot is in this location $newrummage = $activelocation[4] # Loop the rummaging rummagecycle = 0 while rummagecycle < $newrummage # Rummage Randomiser samplerummkey = $RummageMaster.keys.sample rummagerandomiser = $RummageMaster.select { |k,v| k == samplerummkey } activerummagename = rummagerandomiser.values[-1] digtitle = ["Digging around, you find:","You shove aside old food containers and find:","You hold your breath and shove your hand in the bin and find:", "This bin mostly has shredded paper, but you also find:","In this bin you find:","You rummage around and find:"].sample # puts "Digging around you find #{samplerummkey}" #Prints Item ID puts "#{digtitle} #{activerummagename[-1]}" #Prints NAME continueplz # Puts in INVENTORY and deletes from rummage pile $p1inventory.update(rummagerandomiser) $RummageMaster.delete(samplerummkey) rummagecycle += 1 end # puts Inventory after rummaging.... puts "There is nothing else of value in the bin." puts "------------" puts "After your search, you now have a few more items in your bag:" puts "-----------------------------" $p1inventory.each do |itemiD, detailsofbag| #assigned key, value puts "#{detailsofbag[-1]}: #{detailsofbag[-2]}" #tells which item in array to access end $hotjumptag = 'afternoonnoms' puts "-----------------------------" openbag gamewrap end def gamewrap $dayhealthpre = 1 $dayhealthpost = 1 puts "------------" puts "The sun is setting at the end of day #{$daycount}." bagcheck p1statusreport injuryreport deathpointsstatus puts "--------------" daycountcheck continueplz $hotjumptag = 'nightnoms' openbag nightlocselect # new day BEGINS conditionreport end # --- BAG Check # Checks Size of bag def bagcheck bagsize = $p1inventory.length # BAG ALERT if bagsize >= 10 puts "(!) Bag has too many items to carry! Please remove some items!" # Bag remove # NEED TO CODE THIS ie. move frm bag to rummage pile. # puts "Leaves items on the ground." elsif bagsize <= 10 # puts "Your bag can fit ten items. Your bag is not too heavy yet." else puts "Ghost town." end end # ------TRADING BEGINS HERE # ------------ THIS IS PART OF THE CANCEL TRADE SERIES --------- def canceltrade # Confirm cancel of trade # Return items to original hands ie. # OfferHand to p1inventory # Traderhand to trader1invntory # Exit trade and move on to rummage. $activetrader.merge!($tradershand) $p1inventory.merge!($yourhand) $yourhand.delete_if{|k,_| k} $tradershand.delete_if{|k,_| k} # delete holding bays just in case $dropholdingbay.delete_if{|k,_| k} $consumeholdingbay.delete_if{|k,_| k} $dumpholdingbay.delete_if{|k,_| k} $cancelitemholdingbay.delete_if{|k,_| k} puts "(!) Trade is 100% cancelled, all items returned to owners" puts "---------------" puts "Trader grabs the items laid out and shoves them back in his bag." puts "Trader says: Mebbe next time, then." puts "------------------------------------------- " rummagetime end def confirmtrade # do you want to confirm this trade or cancel (ie. canceltrade) # Confirm trade is moving OfferHand to activetrader # and TraderHand to P1inventory. # Exit trade and move on to rummage. puts "This is the trade on the table:" puts "-----" puts "The trader is offering:" $tradershand.each do |itemiD, detailsofitems| #assigned key, value puts "#{detailsofitems[-1]}: #{detailsofitems[-2]}" #tells which item in array to access end puts "---------" puts "You are offering:" $yourhand.each do |itemiD, detailsofpitems| #assigned key, value puts "#{detailsofpitems[-1]}: #{detailsofpitems[-2]}" #tells which item in array to access end puts "---------" puts "What would you like to do?" puts "complete: 100% complete the trade negotiate: renegotiate what's on offer cancel: cancel the trade" puts "------------------------------------------- to proceed:" prompt usertradeconf = $stdin.gets.chomp if usertradeconf == 'complete' puts "---------" puts "(!) Trade 100% completed." puts "---------" puts "The trader shakes your hand, completing the trade." puts "The trader hands over his items and you give him yours." puts "Trader says: See you round!" puts "---------" $activetrader.merge!($yourhand) $p1inventory.merge!($tradershand) $yourhand.delete_if{|k,_| k} $tradershand.delete_if{|k,_| k} # delete holding bays just in case $dropholdingbay.delete_if{|k,_| k} $consumeholdingbay.delete_if{|k,_| k} $dumpholdingbay.delete_if{|k,_| k} $cancelitemholdingbay.delete_if{|k,_| k} puts "--------------" $hotjumptag = 'daytradenoms' openbag rummagetime elsif usertradeconf == 'negotiate' puts "Trader says: Orright, lets look at this again" negphase elsif usertradeconf == 'cancel' puts "Trader says: This deal ends right here." canceltrade else puts "What do you want??" negphase end end def bagtest bagweightcheck = $p1inventory.length #puts bagweightcheck handweightcheck = $yourhand.length #puts handweightcheck barterweight = bagweightcheck + handweightcheck if barterweight >= 11 puts "You cannot fit all those items in your bag!" puts "(!) Your bag can fit 10 items and you have #{barterweight}." puts "negotiate | cancel trade" bartercheckchoice # Bag remove # NEED TO CODE THIS ie. move frm bag to rummage pile. # puts "Leaves items on the ground." elsif barterweight <= 10 #puts "Your bag can fit ten items. Your bag is not too heavy yet." confirmtrade else puts "Ghost town." end end def bartercheckchoice puts "What do you want to do?" bartercheckchoice = $stdin.gets.chomp if bartercheckchoice == "continue" puts "Continue" confirmtrade elsif bartercheckchoice == "cancel" puts "Cancel" canceltrade elsif bartercheckchoice == "negotiate" puts "Let us negotiate" negphase elsif weightcheckchoice == "leave" puts "Cancel" canceltrade else puts "What was that? Hurrumph!" end # ---- # Check the weight of your bag AND the weight of your hand. # If combined more than 10, you have too many items. # If too many items, options are to: Negotiate, Dump Bag items, or Consume bag items. # If not over 10, continue to confirm trade (ie confirmtrade) end def negphase # Time to negotiate. # Add or remove your items (ie. itemgiven or cancelitem) # Rethink the items you want from trader (ie. itemwanted or dropitem) puts " ------------- " puts "Change your offer:" puts "add: add a new items from your bag to give to the trader remove: remove an item you are offering the trader" puts " ------------- " puts "Change what you get from the trader:" puts "look: see what else the trader can give you drop: tell the trader to remove an item from the deal." puts " ------------- " puts "What do you want to do?" puts "------------------------------------------- to proceed:" prompt negdecision = $stdin.gets.chomp if negdecision == 'add' puts "Trader says: Okay, you look in your bag again and see what you can give me!" itemgiven elsif negdecision == 'remove' puts "Trader says: Sure, you might want to hold onto some of that" cancelitem elsif negdecision == 'look' puts "Trader says: Here's what I am trading..." itemwanted elsif negdecision == 'drop' puts "Trader says: You don't need everything I'm offering. Take some out." itemdropped elsif negdecision == 'cancel' puts "Trader says: These items are too good for the likes of you anyway." canceltrade elsif negdecision == 'exit' puts "Trader says: These items are too good for the likes of you anyway." canceltrade elsif negdecision == 'leave' puts "Trader says: These items are too good for the likes of you anyway." canceltrade else end exit (0) end def equalcheck temptycheck givephasepush p1emptycheck puts "--------------------------------------------" puts "The trader is offering:" $tradershand.each do |itemiD, detailsofitems| #assigned key, value puts "#{detailsofitems[-1]}: #{detailsofitems[-2]}" #tells which item in array to access end puts "---------" puts "You are offering:" $yourhand.each do |itemiD, detailsofpitems| #assigned key, value puts "#{detailsofpitems[-1]}: #{detailsofpitems[-2]}" #tells which item in array to access end continueplz puts "Trader looks at your items in your hands, and sizes them up compared to what he is offering." # puts "---------" collectthetvalues = $tradershand.collect {|key,value| value[3] } totaltvalues = collectthetvalues.inject(:+) # puts "The value of what the trader is presenting is:" # puts totaltvalues # puts "---------" collectthep1values = $yourhand.collect {|key,value| value[3] } totalpvalues = collectthep1values.inject(:+) # puts "The value of what you are presenting is:" # puts totalpvalues if totaltvalues < totalpvalues # puts "The trader value is above p1" puts "Trader says: Looks like a mighty fine deal to me..." puts " ------------- " puts "continue: finalise the trade negotiate: take another look at the things" elsif totaltvalues > totalpvalues # puts "The trader value is below p1" puts "Trader says: Now, wait a minute, what you are offering is a joke! What I have is worth more than that! Give me more or ask for less!" puts " ------------- " puts "negotiate: take another look at things cancel: cancel the trade." else totaltvalues == totalpvalues # puts "The trader value is exactly equal" puts "Trader says: I like an honest trade!" puts " ------------- " puts "continue: finalise the trade negotiate: take another look at things" end puts "What would you like to do?" puts "------------------------------------------- to proceed:" prompt equalcheckdecision = $stdin.gets.chomp if equalcheckdecision == 'continue' bagtest elsif equalcheckdecision == 'negotiate' puts "Trader says: Okay, let's have another look at all this!" negphase elsif equalcheckdecision == 'n' puts "Trader says: Okay, let's have another look at all this!" negphase elsif equalcheckdecision == 'cancel' puts "Trader says: We do not need to trade a thing." canceltrade elsif equalcheckdecision == 'leave' puts "Trader says: We do not need to trade a thing." canceltrade elsif equalcheckdecision == 'exit' puts "Trader says: We do not need to trade a thing." canceltrade else puts "We dont need to play no funny games!" canceltrade end # Compare Traderhand and YouRhand. # If trader hand is equal or better, trader is happy. # Options to canceltrade, negotiate (ie. negphase) or continue trade (ie bagtest) # If trader is less than yours, he is unhappy. # Options to negotiate (ie negphase), or canceltrade entirely. end # -- THIS IS THE CANCEL ITEM PHASE SERIES def cancelfinalpush $p1inventory.merge!($cancelitemholdingbay) $cancelitemholdingbay.delete_if{|k,_| k} end def showplayer1shand puts " ------------- " puts "These are the items you have in the trade:" $yourhand.each do |itemiD, detailsofcitems| #assigned key, value puts "#{detailsofcitems[-1]}: #{detailsofcitems[-2]}" #tells which item in array to access end pempemptycheck = $yourhand.empty? if pempemptycheck == true puts "You have no items in the trade." end end def loopnewcitem cancelitem end def cemptycheck cemptycheck = $tradershand.empty? if cemptycheck == true puts "You cannot continue with the trade without selecting something to remove from trade." continueplz cancelitem else # puts "You have selected an item" end end def cancelitem # see traders items #what items do you want from trader? showplayer1shand puts " ------------- " itemtocancel = 0 puts "What item of yours do you want to remove from the trade?" puts "item: Type the name of one item you want to remove from trade." puts "------------------------------------------- to proceed:" prompt itemtocancel = $stdin.gets.chomp puts " ------------- " if $yourhand.has_key?(itemtocancel) activecancelitem = $yourhand[itemtocancel] taggeditem = activecancelitem[-1] puts "Trader says: You want to remove #{itemtocancel}." puts "Trader says: Okay, you can keep that one." continueplz elsif itemtocancel == 'done' cemptycheck puts "Trader says: Okay, if that's everything, lets continue...." cancelfinalpush equalcheck # exit if they do not want anything elsif itemtocancel == 'd' cancelfinalpush cemptycheck puts "Trader says: Okay, if that's everything, let us continue...." cancelfinalpush equalcheck # exit if they do not want anything elsif itemtocancel == 'cancel' puts "Trader says: No need to get your panties in a twist. We do not need to trade..." canceltrade elsif itemtocancel == 'leave' puts "Trader says: No need to get your panties in a twist. We do not need to trade..." canceltrade elsif itemtocancel == 'exit' puts "Trader says: No need to get your panties in a twist. We do not need to trade..." canceltrade else puts "Trader says: Can you repeat that? I'm hard of hearing." continueplz loopnewcitem end #Find the whole key for it it be updated to Trader's hand. desireditemkey = Hash[*$yourhand.assoc(activecancelitem[-1])] # Note: to find $taggeditem, it is in finditem # Push from Trader Inventory to TraderHand. $cancelitemholdingbay.update(desireditemkey) $yourhand.delete_if{|k,_| k == taggeditem} # Shows the trader's hand.... puts "---------" # Offer to loop for more items. puts "Trader asks: Do you want to remove another item?" puts "y: continue removing items from trade n: lets see if its an equal trade now" puts "------------------------------------------- to proceed:" prompt morecancelling = $stdin.gets.chomp if morecancelling == 'y' loopnewcitem elsif morecancelling == 'done' cemptycheck puts "Trader says: Okay, if that's everything, let's continue...." cancelfinalpush equalcheck elsif morecancelling == 'n' cemptycheck puts "Trader says: Okay, if that's everything, let's continue...." cancelfinalpush equalcheck elsif morecancelling == 'cancel' puts "Trader says: You are making me uncomfortable. I am leaving." canceltrade elsif morecancelling == 'leave' puts "Trader says: You are making me uncomfortable. I am leaving." canceltrade elsif morecancelling == 'exit' puts "Trader says: You are making me uncomfortable. I am leaving." canceltrade else puts "Trader says: I will assume that means you done browsing. Let's continue..." equalcheck end end # -------- THIS IS NOW THE DROP PHASE SET ------------------------- def dropfinalpush # puts "Move items from tholdingbay to trader inventory" $activetrader.merge!($dropholdingbay) $dropholdingbay.delete_if{|k,_| k} end def showtradershand puts " ------------- " puts "These are the traders items you want:" $tradershand.each do |itemiD, detailsofitems| #assigned key, value puts "#{detailsofitems[-1]}: #{detailsofitems[-2]}" #tells which item in array to access end tempemptycheck = $yourhand.empty? if tempemptycheck == true puts "You have not selected any items from the trader" end end def loopnewditem itemdropped end def demptycheck demptycheck = $dropholdingbay.empty? if demptycheck == true puts "You have not selected anything to remove from trade." continueplz itemdropped else # puts "You have selected an item" end end def itemdropped showtradershand puts " ------------- " itemdrop = 0 puts "What do you want to remove from trade?" puts "item: Type the name of one item you want to remove from trade" puts "------------------------------------------- to proceed:" prompt itemdrop = $stdin.gets.chomp if $tradershand.has_key?(itemdrop) activedropitem = $tradershand[itemdrop] taggeditem = activedropitem[-1] puts "Trader says: You want to remove #{itemdrop} from the trade?" puts "Trader says: Done." continueplz elsif itemdrop == 'done' demptycheck puts "Trader says: Finished? Let us see if we are even now." dropfinalpush equalcheck # exit if they do not want anything elsif itemdrop == 'd' demptycheck puts "Trader says: Finished? Let us see if we are even now." dropfinalpush equalcheck # exit if they do not want anything elsif itemdrop == 'cancel' puts "Trader says: No need to get your panties in a twist. We do not need to trade..." canceltrade elsif itemdrop == 'leave' puts "Trader says: No need to get your panties in a twist. We do not need to trade..." canceltrade elsif itemdrop == 'exit' puts "Trader says: No need to get your panties in a twist. We do not need to trade..." canceltrade else puts "Trader says: I do not have that. What were you after?" loopnewditem end #Find the whole key for it it be updated to Trader's hand. desireditemkey = Hash[*$tradershand.assoc(activedropitem[-1])] # Note: to find $taggeditem, it is in finditem # Push from Trader Inventory to TraderHand. $dropholdingbay.update(desireditemkey) $tradershand.delete_if{|k,_| k == taggeditem} # Shows the trader's hand.... puts "---------" puts "Trader asks: Do you want to remove another item?" puts "y: keep dropping items from trade n: continue to see if our trade is equal" puts "------------------------------------------- to proceed:" prompt moredropping = $stdin.gets.chomp if moredropping == 'y' puts "------------" puts "The trader is now offering:" $tradershand.each do |itemiD, detailsofitems| #assigned key, value puts "#{detailsofitems[-1]}: #{detailsofitems[-2]}" #tells which item in array to access end puts "--------------" loopnewditem elsif moredropping == 'done' puts "Trader says: Okay, if that's everything, let's continue...." demptycheck dropfinalpush equalcheck elsif moredropping == 'n' demptycheck dropfinalpush equalcheck elsif moredropping == 'cancel' puts "Trader says: You are making me uncomfortable. I am leaving." canceltrade elsif moredropping == 'leave' puts "Trader says: You are making me uncomfortable. I am leaving." canceltrade elsif moredropping == 'exit' puts "Trader says: You are making me uncomfortable. I am leaving." canceltrade else puts "Trader says: I will assume that means you done browsing. Let's continue..." equalcheck end #what items of the traders do you not want to exchange? # see the TraderHand # select item. # Push from TraderHand to TraderInventroy # Offer to loop for more items. # Contiue to equalcheck end # -------- THIS IS NOW THE GIVE ITEM PHASE SET ------------------------- def showp1inventory puts " ------------- " puts "This is what you have in your bag:" $p1inventory.each do |itemiD, detailsofitems| #assigned key, value puts "#{detailsofitems[-1]}: #{detailsofitems[-2]}" #tells which item in array to access p1emptyinventorycheck end end def loopp1newitem itemgiven end def givephasepush p1emptycheck = $yourhand.empty? if p1emptycheck == true itemgiven else # puts "You have selected an item" end end def p1emptycheck p1emptycheck = $yourhand.empty? if p1emptycheck == true puts "You cannot continue with the trade without selecting something to offer." puts "Trader says: Offer something or leave! Things are hard enough right now!" continueplz itemgiven else # puts "You have selected an item" end end def itemgiven # see p1s items #what items do you want from p1? showp1inventory puts " ------------- " itemtogive = 0 puts "What do you want to offer?" puts "item: Type the name of an item to give to the trader" puts "------------------------------------------- to proceed:" prompt itemtogive = $stdin.gets.chomp puts " ------------- " if $p1inventory.has_key?(itemtogive) activepitem = $p1inventory[itemtogive] taggedpitem = activepitem[-1] puts "Out of your bag you pull out some #{itemtogive} and show the trader" elsif itemtogive == 'done' p1emptycheck puts "Trader says: Okay, let us see if we have a square deal here..." equalcheck # exit if they do not want anything elsif itemtogive == 'd' p1emptycheck puts "p1 says: Okay, if that's everything, let us continue...." itemgiven # exit if they do not want anything elsif itemtogive == 'cancel' puts "Trader says: No need to get your panties in a twist. We do not need to trade..." canceltrade timewarp elsif itemtogive == 'leave' puts "Trader says: No need to get your panties in a twist. We do not need to trade..." canceltrade timewarp elsif itemtogive == 'exit' puts "Trader says: No need to get your panties in a twist. We do not need to trade..." canceltrade timewarp else puts "You thought you had that in your bag, but now you are not so sure. Check again..." loopp1newitem end #Find the whole key for it it be updated to p1 's hand. desiredofferkey = Hash[*$p1inventory.assoc(activepitem[-1])] # Note: to find $taggeditem, it is in finditem # Push from p1 Inventory to p1Hand. $yourhand.update(desiredofferkey) $p1inventory.delete_if{|k,_| k == taggedpitem} # Shows the p1's hand.... puts "---------" # Offer to loop for more items. puts "Do you want to offer another item?" puts "y: continue looking in your bag n: you have selected what you want to offer" puts "------------------------------------------- to proceed:" prompt moregiving = $stdin.gets.chomp if moregiving == 'y' puts "------------" puts "You are now offering...:" $yourhand.each do |itemiD, detailsofitems| #assigned key, value puts "#{detailsofitems[-1]}: #{detailsofitems[-2]}" #tells which item in array to access end puts "--------------" loopp1newitem elsif moregiving == 'done' p1emptycheck puts "Trader says: Okay, now let us see if this is a square deal." equalcheck elsif moregiving == 'n' p1emptycheck puts "Trader says: Okay, now let us see if this is a square deal." equalcheck elsif moregiving == 'cancel' puts "Trader says: What are you trying to pull?! I am leaving!" canceltrade exit (0) elsif moregiving == 'leave' puts "Trader says: What are you trying to pull?! I am leaving!" canceltrade exit (0) elsif moregiving == 'exit' puts "Trader says: What are you trying to pull?! I am leaving!" canceltrade exit (0) else puts "Trader says: I do not have all day. Let us get a move on..." equalcheck end end # -------- THIS IS NOW THE SELECT TRADER ITEM PHASE SET ------------------------- def showtradersinventory puts " ------------- " puts "The trader shows you the items in his trolley:" $activetrader.each do |itemiD, detailsofitems| #assigned key, value puts "#{detailsofitems[-1]}: #{detailsofitems[-2]}" #tells which item in array to access end end def loopnewitem itemwanted end def temptycheck temptycheck = $tradershand.empty? if temptycheck == true puts "You cannot continue with the trade without selecting something." puts "Trader says: What are you trying to rob me?! Choose something or leave!" continueplz itemwanted else # puts "You have selected an item" end end def itemwanted # see traders items #what items do you want from trader? showtradersinventory puts " ------------- " itemwanted = 0 puts "Trader says: See anything you like?" puts "------------------------------------------- to proceed:" puts "item: Type the name of one item you want" puts "done: continue trading" puts "cancel: cancel trading" prompt itemwanted = $stdin.gets.chomp puts " ------------- " if $activetrader.has_key?(itemwanted) activeitem = $activetrader[itemwanted] taggeditem = activeitem[-1] puts "Trader says: You want #{itemwanted}? I've got it here." elsif itemwanted == 'done' temptycheck puts "Trader says: Okay. If you've selected everything you want, let's continue." puts "------------------------------------------- to proceed:" continueplz equalcheck # exit if they do not want anything elsif itemwanted == 'd' temptycheck puts "Trader says: Okay. If you've selected everything you want, let's continue." puts "------------------------------------------- to proceed:" continueplz equalcheck # exit if they do not want anything elsif itemwanted == 'cancel' puts "Trader says: No need to get your panties in a twist. We do not need to trade..." canceltrade elsif itemwanted == 'leave' puts "Trader says: No need to get your panties in a twist. We do not need to trade..." canceltrade elsif itemwanted == 'exit' puts "Trader says: No need to get your panties in a twist. We do not need to trade..." canceltrade else puts "Trader says: I do not understand. Can you say that again?" continueplz loopnewitem end #Find the whole key for it it be updated to Trader's hand. desireditemkey = Hash[*$activetrader.assoc(activeitem[-1])] # Note: to find $taggeditem, it is in finditem # Push from Trader Inventory to TraderHand. $tradershand.update(desireditemkey) $activetrader.delete_if{|k,_| k == taggeditem} # Shows the trader's hand.... puts "---------" # Offer to loop for more items. puts "Trader asks: Do you want another item?" puts "y: select more items from the trader n: continue on with the trade" puts "------------------------------------------- to proceed:" prompt moretrading = $stdin.gets.chomp if moretrading == 'y' puts " ------------- " puts "The trader's deal consists of these items:" $tradershand.each do |itemiD, detailsofitems| #assigned key, value puts "#{detailsofitems[-1]}: #{detailsofitems[-2]}" #tells which item in array to access end loopnewitem elsif moretrading == 'done' temptycheck puts "Trader says: Okay. If you've selected everything you want, let's continue." continueplz equalcheck elsif moretrading == 'n' temptycheck puts "Trader says: Okay. If you've selected everything you want, now open up that bag let's continue." continueplz equalcheck elsif moretrading == 'cancel' puts "Trader says: You are making me uncomfortable. I am leaving." canceltrade elsif moretrading == 'leave' puts "Trader says: You are making me uncomfortable. I am leaving." canceltrade elsif moretrading == 'exit' puts "Trader says: You are making me uncomfortable. I am leaving." canceltrade else puts "Trader says: I will assume that means you done browsing. Let's continue..." negphase end end def weightcheckloop weightcheck end def weightcheck # If bag > 7, then give options to dump, consume, or keep going to itemwanted # Checks Size of bag weightcheck = $p1inventory.length # puts weightcheck #weightcheck = 20 # BAG ALERT if weightcheck >= 10 puts "You suddenly realise your bag is feeling quite heavy..." puts "(!) Your bag can fit 10 items and you have #{weightcheck}." puts "What do you want to do?" puts "dump: throw away some items consume: eat or use some items to clear up space in your bag cancel: cancel the trade" puts "------------------------------------------- to proceed:" prompt weightcheckamend # Bag remove # NEED TO CODE THIS ie. move frm bag to rummage pile. # puts "Leaves items on the ground." elsif weightcheck >= 6 && weightcheck <=9 puts "..." puts "You realise your bag is feeling pretty full..." puts "(!) Your bag can fit 10 items and you have #{weightcheck} items already!" puts "Type what you would like to do:" puts "continue: continue to trade cancel: cancel this trade consume: use some some items to clear space dump: dump some items into a bin" weightcheckamend elsif weightcheck <= 5 # puts "Your bag can fit ten items. Your bag is not too heavy yet." else puts "Ghost town." end end def weightcheckamend #puts "WEIGHTCHECKAMEND" puts "What do you want to do?" puts "----------------------type your response to proceed:" puts "> " weightcheckchoice = $stdin.gets.chomp if weightcheckchoice == "continue" itemwanted elsif weightcheckchoice == "cancel" canceltrade elsif weightcheckchoice == "consume" consumeitemintro weightcheckloop elsif weightcheckchoice == "dump" itemtodump weightcheckloop elsif weightcheckchoice == "leave" else puts "What was that? Hurrumph!" end end def tradershuffle #reset activetrader $activetrader = 0 # select randomnumber randomnumber = 0 prng = Random.new randomnumber = prng.rand(1..50) #if number is even, trader one, if odd, trader 2 if randomnumber&1==0 $activetrader = $trader1inventory else $activetrader = $trader2inventory end end def tradeenter tradershuffle #puts $activetrader puts "A man with a trolley full of items pauses next to you." puts "The trader says: I am willing to trade some goods if you want." weightcheck puts "The trader asks: So do you want to trade? y: Let's trade n: I don't want to trade." puts "---------------------------your your answer to proceed:" prompt leavetotradeconf = $stdin.gets.chomp if leavetotradeconf == 'y' weightcheck itemwanted elsif leavetotradeconf == 'n' puts "The trader says: I've got better things to do with my time anyhow..." puts " " else puts "The trader says: Well, another time then." end end # ------TRADING ENDS HERE # -------------------------- # Trader Check is trader at location? def tradercheck if $activelocation[-2] == 'traderhere' # puts "It looks like someone here is willing to trade." tradeenter elsif $activelocation[-2] == 'notrade' #puts "No trader here. No one is around." else puts "Ghost town." end end # -------------------------- #LOCATION STARTS def locationstart #puts 'We have arrived at your location' # APPLIES LOCATION STATS puts $activelocation[-1] #locationdescription continueplz $p1stats['food'] += $activelocation[0] $p1stats['safety'] += $activelocation[1] $p1stats['warmth'] += $activelocation[2] #EVENTS AT LOCATION #How many Events happen in the park locevents = $activelocation[3] # Loop to display te number of park events venuestart = 0 while venuestart < locevents # puts "Triggering event cycle" $newevent = $EventsMaster[$EventsMaster.keys.sample] #Lists the event that happened puts $newevent[-1] #applies event stats to P1 $p1stats['food'] += $newevent[0] $p1stats['safety'] += $newevent[1] $p1stats['warmth'] += $newevent[2] $istraderevent = $newevent[3] # puts "Check for trader event" if $istraderevent == 'traderhere' tradeenter elsif $istraderevent == 'notrade' # puts "No trader is around to trade with." else puts "(!) Typo detected" end #trigger to loop until met venue events venuestart += 1 continueplz end # END OF EVENT CYCLE #puts " ------------- " #puts "You look around this location. Is anyone else here?" #Go to trader check tradercheck rummagetime end # --------------------------------------------- # LOCATION SELECTION def locationloop locationselect end def locationselect puts "Where do you want to go today?" puts "Consider how you are feeling and what resources you need to find." puts " " puts "Your options are:" $LocationsMaster.each do |itemiD, detailsofpitems| #assigned key, value puts "---------" puts "#{itemiD} - #{detailsofpitems[-1]}" #tells which item in array to access end puts "------------------------------------type location to proceed:" puts ">" getlocation = $stdin.gets.chomp if getlocation == "Park" then $activelocation = $LocationsMaster["Park"] locationstart elsif getlocation == "Supermarket" $activelocation = $LocationsMaster["Supermarket"] locationstart elsif getlocation == "Bus Shelter" $activelocation = $LocationsMaster["Bus Shelter"] locationstart elsif getlocation == "Flinders Street Station" $activelocation = $LocationsMaster["Flinders Street Station"] locationstart elsif getlocation == "cancel" exit(0) elsif getlocation == "exit" exit(0) else puts "(!) Typo detected. Please try again." locationloop end end #### CONDITION REPORT AND START def conditionreport $hotjumptag = 'morningnoms' puts "The sun rises on day #{$daycount}." puts "___________________" puts " " puts "It's been a long night." p1statusreportmorning deathpointsstatus #Bag items at start of day puts "___________________" puts " " puts "In your bag you have:" $p1inventory.each do |itemiD, detailsofbag| #assigned key, value puts "#{detailsofbag[-1]}: #{detailsofbag[-2]}" #tells which item in array to access end puts "-----------------" $hotjumptag = 'morningnoms' openbag puts "----------------" locationselect end def storybegins $daycount = 1 $deathpoints = 0 $dayhealthpre = 1 $dayhealthpost = 1 puts "___________________" puts "——— STREET SURVIVAL —————" puts "HOW TO PLAY -" puts "Do you have what it takes to survive on the street until the end of winter?" puts "You will need to find somewhere to stay in the day, and somewhere to sleep at night." puts "You will need to find, or trade for, food." puts "You need to keep warm, and if you get too injured on the street, you might not survive very long." puts "You've got a backpack with a few items to help the first few days." puts "Most of all, you need to try to stay positive. Good luck!" puts "___________________" puts " " puts "The company you worked at went bust a few weeks ago." puts "All too quickly, you found yourself living off credit cards, with bills backing up and no one hiring." puts "You were sleeping on friend’s couches when you couldn't afford rent." puts "Until you felt you were pushing your luck by asking to stay another night." puts "..." puts "From now on, you are trying your luck on the street." continueplz conditionreport end storybegins
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more