wander.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. // Exploring/Hunting
  2. /*jshint multistr:true*/
  3. function getPlaceCnt(place)
  4. {
  5. if (isNaN(places[place])) return 0;
  6. return places[place];
  7. }
  8. function setPlaceVisited(place)
  9. {
  10. if (isNaN(places[place])) places[place] = 1;
  11. else places[place] += 1;
  12. }
  13. function Forage()
  14. {
  15. if ($("#forage_buttons").is(":visible")) {
  16. $("#camp_feed").html("");
  17. return;
  18. }
  19. if ($("#women_buttons").is(":visible")) resetRival();
  20. if (player.round > 10 && getPlaceCnt("Volcano") === 0) {
  21. setPlaceVisited("Volcano");
  22. Message(NextWindow, "<h2>Fire Mountain?</h2>\
  23. <p>You see a mountain smoking with red rivers flowing down it's side. Looks dangerous, but maybe you return there another time?");
  24. return;
  25. }
  26. $("#camp_feed").html(
  27. "<h2>Where do you forage?</h2>\
  28. <div id='forage_buttons' class='push--top'></div>\
  29. <div id='forage_display'></div>");
  30. // add places
  31. $("#forage_buttons").append("\
  32. <button id='forage_button_forest' class='btn btn-woman push--right' title='Forest'>Forest</button>\
  33. <button id='forage_button_hills' class='btn btn-woman push--right' title='Hills'>Hills</button>\
  34. ");
  35. if (getPlaceCnt("Swamp") !== 0) {
  36. $("#forage_buttons").append("<button id='forage_button_swamp' class='btn btn-woman push--right' title='Explore the volcano'>Swamp</button>");
  37. $("#forage_button_swamp").click(
  38. function(){
  39. if (FindRandomEvent("Swamp")) return;
  40. var val = getRandomInt(1, 100);
  41. if (val < 10) WanderFood("<h1>Found: Small Melon</h1><p>You find small strange melon, it may feed your clan</p>", "eatSmallMelonYou", "eatSmallMelonWoman", 1);
  42. else if (val < 20) WanderFood("<h1>Found: Mushroom</h1><p>You find strange mushroom, with long and stiff shape, it may feed your clan</p>", "eatMushroomYou", "eatMushroomWoman", 1);
  43. else if (val < 30) WanderFood("<h1>Found: Heavy Melon</h1><p>You find strange and heacy melon, it may feed your clan</p>", "eatMelonYou", "eatMelonWoman", 2);
  44. else if (val < 35) WanderFood("<h1>Found: Large Swollen Nut</h1><p>You find small nut, you feel the force of your ancestors in it</p>", "eatMaternalNutYou", "eatMaternalNutWoman", 2);
  45. else if (val < 55) WanderFood("<h1>Found: Tough Nut</h1><p>You find small nut, you feel the force of your ancestors in it</p>", "eatDominationNutYou", "eatDominationNutWoman", 1);
  46. else if (val < 65) WanderFood("<h1>Found: Green Berry</h1><p>You find small green berry that smells strange, it may feed your clan</p>", "eatGreenBerryYou", "eatGreenBerryWoman", 1);
  47. else if (val < 75) WanderFood("<h1>Found: Pale Berry</h1><p>You find small pale berry that smells strange, it may feed your clan</p>", "eatPaleBerryYou", "eatPaleBerryWoman", 1);
  48. else if (val < 85) WanderFood("<h1>Found: Dark Berry</h1><p>You find small dark coloured berry that smells strange, it may feed your clan</p>", "eatDarkBerryYou", "eatDarkBerryWoman", 1);
  49. else if (val < 95) WanderFood("<h1>Found: Rainbow Flower</h1><p>You find small multicoloured flower that looks surprisingly edible, it may feed your clan</p>", "eatRainbowflowerYou", "eatRainbowflowerWoman", 1);
  50. else WanderBattle("cold swamp");
  51. }
  52. );
  53. };
  54. if (getPlaceCnt("Beach") !== 0) {
  55. $("#forage_buttons").append("<button id='forage_button_beach' class='btn btn-woman push--right' title='Explore the volcano'>Beach</button>");
  56. $("#forage_button_beach").click(
  57. function(){
  58. if (FindRandomEvent("Beach")) return;
  59. var val = getRandomInt(1, 100);
  60. if (val < 20) WanderFood("<h1>Found: Swollen Nut</h1><p>You find small nut, you feel the force of your ancestors in it</p>", "eatMaternalNutYou", "eatMaternalNutWoman", 1);
  61. else if (val < 35) WanderFood("<h1>Found: Mushroom</h1><p>You find strange mushroom, with long and stiff shape, it may feed your clan</p>", "eatMushroomYou", "eatMushroomWoman", 1);
  62. else if (val < 50) WanderFood("<h1>Found: Pretty Nut</h1><p>You find small nut, you feel the force of your ancestors in it</p>", "eatAllureNutYou", "eatAllureNutWoman", 1);
  63. else if (val < 65) WanderFood("<h1>Found: Paw Fruit</h1><p>You find small fruit look like paw, you feel the force of your ancestors in it</p>", "eatPawFruitYou", "eatPawFruitWoman", 1);
  64. else if (val < 80) WanderFood("<h1>Found: Tri-Sea-thing</h1><p>You find strange sea creature, long and slimy with three bodies, it may feed your clan</p>", "eatTriCreatureYou", "eatTriCreatureWoman", 1);
  65. else if (val < 90) WanderFood("<h1>Found: Hairy Nut</h1><p>You find a large nut, it may feed your clan</p>", "eatHairyNutYou", "eatHairyNutWoman", 1);
  66. else if (val < 95) WanderNothing();
  67. else WanderBattle("chilly beach");
  68. }
  69. );
  70. };
  71. if (getPlaceCnt("Volcano") !== 0) {
  72. $("#forage_buttons").append("<button id='forage_button_volcano' class='btn btn-woman push--right' title='Explore the volcano'>Volcano</button>");
  73. $("#forage_button_volcano").click(
  74. function(){
  75. if (FindRandomEvent("Volcano")) return;
  76. var val = getRandomInt(1, 100);
  77. if (val < 20) WanderFood("<h1>Found: Tough Nut</h1><p>You find small nut, you feel the force of your ancestors in it</p>", "eatDominationNutYou", "eatDominationNutWoman", 1);
  78. else if (val < 45) WanderFood("<h1>Found: Pretty Nut</h1><p>You find small nut, you feel the force of your ancestors in it</p>", "eatAllureNutYou", "eatAllureNutWoman", 1);
  79. else if (val < 65) WanderFood("<h1>Found: Long Nut</h1><p>You find long nut, you feel the force of your ancestors in it</p>", "eatOrientationNutYou", "eatOrientationNutWoman", 1);
  80. else if (val < 85) WanderFood("<h1>Found: Large Swollen Nut</h1><p>You find small nut, you feel the force of your ancestors in it</p>", "eatMaternalNutYou", "eatMaternalNutWoman", 2);
  81. else if (val < 95) WanderFood("<h1>Found: Red Nut</h1><p>You find small red nut that smells of fire, it may feed your clan</p>", "eatDemonNutYou", "eatDemonNutWoman", 1);
  82. else if (val < 95) WanderFood("<h1>Found: Split Mushroom</h1><p>You find strange mushroom, with long and stiff shape and two stalks, it may feed your clan</p>", "eatTwinMushroomYou", "eatTwinMushroomWoman", 1);
  83. else WanderBattle("hot volcano");
  84. }
  85. );
  86. }
  87. if (smith.goods > 0) {
  88. $("#forage_buttons").append("<button id='forage_button_smith' class='btn btn-woman push--right' title='Visit Smith'>Visit " + smith.name + "</button>");
  89. $("#forage_button_smith").click(function(){TradeSmith();});
  90. }
  91. $("#forage_button_forest").click(
  92. function(){
  93. if (FindRandomEvent("Forest")) return;
  94. var val = getRandomInt(1, 100);
  95. if (val < 20) WanderFood("<h1>Found: Tough Nut</h1><p>You find small nut, you feel the force of your ancestors in it</p>", "eatDominationNutYou", "eatDominationNutWoman", 1);
  96. else if (val < 40) WanderFood("<h1>Found: Pretty Nut</h1><p>You find small nut, you feel the force of your ancestors in it</p>", "eatAllureNutYou", "eatAllureNutWoman", 1);
  97. else if (val < 50) WanderFood("<h1>Found: Mushroom</h1><p>You find strange mushroom, with long and stiff shape, it may feed your clan</p>", "eatMushroomYou", "eatMushroomWoman", 1);
  98. else if (val < 70) WanderFood("<h1>Found: Grapes</h1><p>You find some odd grapes, with double berries, it may feed your clan</p>", "eatGrapesYou", "eatGrapesWoman", 1);
  99. else if (val < 95) WanderFood("<h1>Found: Melon</h1><p>You find strange melon, it may feed your clan</p>", "eatMelonYou", "eatMelonWoman", 1);
  100. else WanderBattle("snow forest");
  101. }
  102. );
  103. $("#forage_button_hills").click(
  104. function(){
  105. if (FindRandomEvent("Hills")) return;
  106. var val = getRandomInt(1, 100);
  107. if (val < 20) WanderFood("<h1>Found: Clean Nut</h1><p>You find small nut, you feel the force of your ancestors in it</p>", "eatDomesticNutYou", "eatDomesticNutWoman", 1);
  108. else if (val < 35) WanderFood("<h1>Found: Long Nut</h1><p>You find long nut, you feel the force of your ancestors in it</p>", "eatOrientationNutYou", "eatOrientationNutWoman", 1);
  109. else if (val < 50) WanderFood("<h1>Found: Mushroom</h1><p>You find strange mushroom, with long and stiff shape, it may feed your clan</p>", "eatMushroomYou", "eatMushroomWoman", 1);
  110. else if (val < 75) WanderFood("<h1>Found: White Nut</h1><p>You find small white nut that smells of milk, it may feed your clan</p>", "eatMilkNutYou", "eatMilkNutWoman", 1);
  111. else if (val < 85) WanderFood("<h1>Found: Melon</h1><p>You find strange melon, it may feed your clan</p>", "eatMelonYou", "eatMelonWoman", 1);
  112. else if (val < 95) {
  113. if (smith.goods > 0) WanderFood("<h1>Found: Pretty Nut</h1><p>You find small nut, you feel the force of your ancestors in it</p>", "eatAllureNutYou", "eatAllureNutWoman", 1);
  114. else if (smith.round > 0) TradeSmith();
  115. else MeetSmith();
  116. }
  117. else WanderBattle("snow hills");
  118. }
  119. );
  120. }
  121. function Hunt()
  122. {
  123. if ($("#wander_buttons").is(":visible")) {
  124. $("#camp_feed").html("");
  125. return;
  126. }
  127. if ($("#women_buttons").is(":visible")) resetRival();
  128. if (player.round > 10 && getPlaceCnt("Volcano") === 0) {
  129. setPlaceVisited("Volcano");
  130. EndRound(Message(NextWindow, "<h2>Fire Mountain?</h2>\
  131. <p>You see a mountain smoking with red rivers flowing down it's side. Looks dangerous, but maybe you return there another time?"));
  132. return;
  133. }
  134. $("#camp_feed").html(
  135. "<h2>Where do you hunt?</h2>\
  136. <div id='wander_buttons' class='push--top'></div>\
  137. <div id='wander_display'></div>");
  138. //$.each(places, function(index, place) { $("#wander_display").append(index + ": " + place + ", "); });
  139. // add places
  140. $("#wander_buttons").append("\
  141. <button id='wander_button_forest' class='btn btn-woman push--right' title='Forest'>Forest</button>\
  142. <button id='wander_button_hills' class='btn btn-woman push--right' title='Hills'>Hills</button>\
  143. ");
  144. if (getPlaceCnt("Swamp") !== 0) {
  145. $("#wander_buttons").append("<button id='wander_button_swamp' class='btn btn-woman push--right' title='Swamp'>Swamp</button>");
  146. $("#wander_button_swamp").click(
  147. function(){
  148. if (FindRandomEvent("Swamp")) return;
  149. WanderBattle("cold swamp");
  150. }
  151. );
  152. };
  153. if (getPlaceCnt("Beach") !== 0) {
  154. $("#wander_buttons").append("<button id='wander_button_beach' class='btn btn-woman push--right' title='Beach'>Beach</button>");
  155. $("#wander_button_beach").click(
  156. function(){
  157. if (FindRandomEvent("Beach")) return;
  158. WanderBattle("chilly beach");
  159. }
  160. );
  161. };
  162. if (getPlaceCnt("Volcano") !== 0) {
  163. $("#wander_buttons").append("<button id='wander_button_volcano' class='btn btn-woman push--right' title='Explore the volcano'>Volcano</button>");
  164. $("#wander_button_volcano").click(
  165. function(){
  166. if (FindRandomEvent("Volcano")) return;
  167. var val = getRandomInt(1, 7);
  168. if (getPlaceCnt("Volcano") == 2) val = 0;
  169. if (val < 4) MeetDemon();
  170. else WanderBattle("hot volcano");
  171. }
  172. );
  173. }
  174. $("#wander_button_forest").click(
  175. function(){
  176. if (FindRandomEvent("Forest")) return;
  177. WanderBattle("snow forest");
  178. }
  179. );
  180. $("#wander_button_hills").click(
  181. function(){
  182. if (FindRandomEvent("Hills")) return;
  183. if (player.round > 15 && smith.round === 0) {
  184. MeetSmith();
  185. return;
  186. }
  187. var val = getRandomInt(1, 7);
  188. if (val < 3 && smith.round > 0 && smith.goods === 0) TradeSmith();
  189. else WanderBattle("snow hills");
  190. }
  191. );
  192. }
  193. // Find a rival
  194. function WanderBattle(plc)
  195. {
  196. if (player.women.length === 0) {
  197. MeetThoth();
  198. return;
  199. }
  200. if(player!==leader){//for now, no fights if not the leader of the camp.
  201. Message(NextWindow,`<p>You find nothing. Return to ${leader.name} empty handed.</p>`);
  202. EndRound();
  203. return;
  204. }
  205. rival = undefined;
  206. // A quest?
  207. // - Hunt for Weshptah
  208. checkBoss1(plc);
  209. if (rival === undefined) {
  210. // Any runaways
  211. if (runaways.length > 0 && getRandomInt(1, 100) < 10) {
  212. rival = runaways[getRandomInt(0, runaways.length - 1)];
  213. rival.experience += 5;
  214. EncounterNamedRival();
  215. } else {
  216. // Generic Rival
  217. var exp = Math.floor(player.getTrainingRanks() * (getRandomInt(40, 120) / 100)) * 5;
  218. createRival(exp);
  219. }
  220. }
  221. var bAvoid = player.Mods.perception > 0 && (player.Mods.perception * 5) >= getRandomInt(0, 100);
  222. var str = "<h1>Wandering</h1><p>You wander through " + plc + " until spot lone man";
  223. if (bAvoid) {
  224. // can avoid
  225. str += ". He no see you yet";
  226. }
  227. str += " " + rival.getRecognise();
  228. if (bAvoid) {
  229. str += ".<div id='fight_buttons' class='push--top'></div>" +
  230. "<button id='fight_button_fight' class='btn btn-woman push--right' title='Take him!'>Fight</button>" +
  231. "<button id='fight_button_leave' class='btn btn-woman push--right' title='Leave'>Leave</button>";
  232. } else {
  233. str += ". He see you and grin. He think you become womanfolk of his clan. He wrong.</p>";
  234. str += ".<div id='fight_buttons' class='push--top'></div>" +
  235. "<button id='fight_button_fight' class='btn btn-woman push--right' title='Take him!'>Fight</button>"
  236. }
  237. str += "<button id='fight_button_auto' class='btn btn-woman push--right' title='Auto Fight'>Quick Fight</button>";
  238. $("#output").html(str);
  239. $("#fight_button_fight").click(
  240. function(){
  241. Battle(rival, false);
  242. }
  243. );
  244. $("#fight_button_leave").click(
  245. function() {
  246. Message(NextWindow, "You no want this weakling and leave him.");
  247. EndRound();
  248. }
  249. );
  250. $("#fight_button_auto").click(
  251. function() {
  252. Battle(rival, true);
  253. }
  254. );
  255. }
  256. // Found a consumable item (common function)
  257. function WanderFood(desc, actionyou, actionwoman, pow)
  258. {
  259. $("#output").html(desc);
  260. $("#output").append("<h2>Who will eat it?</h2>\
  261. <div id='eat_buttons' class='push--top'>\
  262. <button id='eat_button_you' class='btn btn-woman push--right'>You (Raw)</button></div>");
  263. $("#eat_button_you").click(function(){eval(actionyou + "(false, " + pow + ")");EndRound();});
  264. if (player.Mods.infuse > 0 && player.goods > 0) {
  265. $("#eat_buttons").append("<button id='eat_button_you_infuse' class='btn btn-woman push--right'>You (Cooked)</button>");
  266. $("#eat_button_you_infuse").click(function(){
  267. fBefore = player.isFemale();
  268. eval(actionyou + "(true, " + pow + ")");
  269. EndRound();
  270. });
  271. }
  272. function drawEatButton(person,index){
  273. if (person.isFutanari()) {$("#eat_buttons").append("<button id='woman_button_"+index+"' class='btn btn-futa push--right'>"+person.name+"</button>");
  274. }else if (person.isFemale()) {$("#eat_buttons").append("<button id='woman_button_"+index+"' class='btn btn-woman push--right'>"+person.name+"</button>");
  275. }else {$("#eat_buttons").append("<button id='woman_button_"+index+"' class='btn btn-man push--right'>"+person.name+"</button>");}
  276. $("#woman_button_"+index).click(function(){
  277. if ($("#woman_eat_buttons").is(":visible")) {
  278. $("#eat_button_Woman").unbind('click').click(function(){
  279. eval(actionwoman + "(false, " + pow + ")");
  280. EndRound();
  281. });
  282. $("#eat_button_Woman_Cooked").unbind('click').click(function(){
  283. eval(actionwoman + "(true, " + pow + ")");
  284. EndRound();
  285. });
  286. } else {
  287. $("#eat_buttons").append("<div id='woman_eat_buttons' class='push--top'>\
  288. <button id='eat_button_Woman' class='btn btn-woman push--right'>Choose (Raw)</button>\</div>");
  289. $("#eat_button_Woman").click(function(){
  290. eval(actionwoman + "(false, " + pow + ")");
  291. EndRound();
  292. });
  293. if (player.Mods.infuse > 0 && player.goods > 0) {
  294. $("#woman_eat_buttons").append("<button id='eat_button_Woman_Cooked' class='btn btn-woman push--right'>Choose (Cooked)</button>");
  295. $("#eat_button_Woman_Cooked").click(function(){
  296. eval(actionwoman + "(true, " + pow + ")");
  297. EndRound();
  298. });
  299. }
  300. }
  301. rival = person;
  302. fBefore = rival.isFemale();
  303. $(".stats").show();
  304. $("#otherstats").show();
  305. redraw();
  306. });
  307. };
  308. if(player===leader){
  309. $.each(leader.women, function( index, value ) {
  310. drawEatButton(leader.women[index],index);
  311. });
  312. }else{
  313. drawEatButton(leader,"leader");
  314. }
  315. $("#eat_buttons").append("<button id='eat_button_throw' class='btn btn-woman push--right'>Other Use</button>");
  316. $("#eat_button_throw").click(function(){
  317. var bonus = leader.women.filter(x=>x.dysphoria-getRandomInt(0,30)<=0).reduce((x,w)=>w.domesticity/30+x,2);//get more if there's a bunch of women.
  318. player.goods += bonus;
  319. Message(NextWindow, "<h1>Other Use</h1><p>You store it away to be used as needed for crafting.</p>");
  320. EndRound();
  321. });
  322. }
  323. function FindRandomEvent(plc)
  324. {
  325. setPlaceVisited(plc);
  326. if (getRandomInt(1, 100) > 10) return false; // No event
  327. var val = getRandomInt(1, 100);
  328. if (val < 10 && getPlaceCnt("Swamp") == 0) {
  329. setPlaceVisited("Swamp");
  330. Message(NextWindow, "<h1>Swamp</h1><p>You find a foul smelling wet place, full of many things to hunt, you must return here</p>");
  331. } else if (val < 50) FindAbandonedCamp();
  332. else WanderNothing();
  333. EndRound();
  334. return true;
  335. }
  336. // Find nothing
  337. function WanderNothing()
  338. {
  339. Message(NextWindow, "<h1>Failure</h1><p>You failed to hunt anything or anyone, and return to camp</p>");
  340. }
  341. // find abandoned camp
  342. function FindAbandonedCamp()
  343. {
  344. player.goods += getRandomInt(1, 10);
  345. var val = getRandomInt(1, 100);
  346. if (val < 25) Message(NextWindow, "<h1>Abandoned Camp</h1><p>You find a camp for a clan, look like it not used for long time. You find some things left behind and take back to your camp.</p>");
  347. else if (val < 50) Message(NextWindow, "<h1>Raided Camp</h1><p>You find a camp for a clan, it damaged, most things are burned. You see signs of people dragged away. You find some things left behind and take back to your camp.</p>");
  348. else if (val < 75) {
  349. if (getPlaceCnt("Volcano") !== 0 && !player.checkSwitch(1)) {
  350. rival = new Avatar(20, 60, 70, 70, 80);
  351. rival.Mods.breasts = 200;
  352. rival.name = "Osiris";
  353. redraw();
  354. $("#output").html(
  355. '<h1>Raided Camp</h1><p>You find a camp for a clan, it damaged, most things are burned. You look and find some things left behind and take back to your camp.</p>\
  356. <p>As you gather a woman challenges you!<br>\
  357. "Stop, this not your clan!"<br>\
  358. She has huge breasts, and looks at you defiantly<br>\
  359. "My man..was taken by a red woman away to the mountain of fire..but he return..soon"<p>\
  360. <p>You see she not believe it, and you think her man now serving that woman, as slave or full of her babies. You tell woman you take care of her and she become member of your clan. She look confused, wanting to wait for her man, but wanting safety of a clan</p>\
  361. <button id="take_woman" class="btn">Take Woman</button>\
  362. <button id="reject_woman" class="btn">Reject Woman</button>\
  363. ');
  364. redraw();
  365. $("#take_woman").click(function () {
  366. rival.dysphoria = 0;
  367. redraw();
  368. $(".stats").hide();
  369. player.women.push(rival);
  370. Message(NextWindow, "<h1>" + rival.name + "</h1>\
  371. <p>You tell her that she now your woman! Her man now slave of red woman, and no hope for him. She say,<br>\
  372. <p>&quot;Me be your woman if you give me oath on your anccestors, take that red woman as slave!</p>\
  373. <p>This your desire so you give oath on ancestors spirits. She laugh in joy and tell you her name 'Osiris'</p>\
  374. ");
  375. });
  376. $("#reject_woman").click(function() {
  377. Message(NextWindow, "You tell her to wait for her man. She look hopeful, you doubt you see her again.");
  378. });
  379. player.setSwitch(1);
  380. } else Message(NextWindow, "<h1>Raided Camp</h1><p>You find a camp for a clan, it damaged, most things are burned. You see signs of people dragged away. You find some things left behind and take back to your camp.</p>");
  381. }
  382. else Message(NextWindow, "<h1>A Clan No More</h1><p>You find a camp for a clan, it is empty, and you think it one that died out in the long winter and no women-folk. Sadly you look around and find some things abandoned and take back to your camp.</p>");
  383. }