Fix hair, dick around with new game screen.
[18plus-7leafadventure.git] / src / org / sevenchan / dongs / enchantment / Hunger.as
blob4dc69c80da945d5e8d7d45ca424889c7347e22d6
1 package org.sevenchan.dongs.enchantment
3 import org.sevenchan.dongs.Creature;
4 import org.sevenchan.dongs.Item;
5 import org.sevenchan.dongs.screens.CombatScreen;
6 import org.sevenchan.dongs.screens.InfoScreen;
7 import flash.net.registerClassAlias;
8 /**
9 * Require user to obtain one or more items in order to fend off curse.
10 * - Forces use of item when obtained
11 * - If opponent has item, force either surrender or attack, depending on how to get the item
12 * - 1 HP each turn
13 * @author ...
15 public class Hunger extends Enchantment
18 registerClassAlias("EHunger", Corruption);
19 public var forWhat:int = 0;
20 public var amount:Number = 0;
21 private var host:Creature;
22 public var item:Item;
23 public function Hunger(_forWhat:int, _howMuch:Number)
25 super();
26 this.forWhat = _forWhat;
27 this.amount = _howMuch;
29 override public function onInit(newHost:Creature):String
31 host = newHost;
32 cancelAddition = false;
33 this.item = Item.findByID(forWhat);
34 InfoScreen.push("<h2>Hunger</h2><p>You are now hungry for " + amount + " " + item.name + ".</p><p>Check your appearance screen to see your effects.</p>");
35 return "You are now hungry."
37 override public function getName():String
39 return "Hunger";
41 override public function getID():String
43 return "hunger";
46 override public function getDescr():String
48 return "You are hungry for "+amount+"x "+item.name+".";
51 private function haveItemsNeeded():Boolean {
52 if (this.host.hasItem(forWhat)) {
53 var i:int = 0;
54 for each (var item:Item in this.host.inventory) {
55 if (item.id == forWhat) {
56 if (item.amount >= amount) {
57 return true;
62 return false;
65 override public function onMyCombatTurn(screen:CombatScreen,other:Creature):Boolean
67 if (other.hasItem(forWhat)) {
68 if (item.isSexuallyTransmitted) {
69 screen.passAction = CombatScreen.PASS_SKIP;
70 InfoScreen.push("<h2>Hunger</h2><p>You're too hungry to think about anything other than " + other.getTypeName() + "'s " + item.name + "!</p>");
71 return false;
72 } else {
73 screen.passAction = CombatScreen.PASS_SKIP;
74 InfoScreen.push(other.gender.doReplace("<h2>Hunger</h2><p>You're too hungry to think about anything other than " + other.getTypeName() + "'s " + item.name + ", and viciously attack %CSUB%!</p>"));
75 return false;
78 host.HP --;
79 return false;
82 override public function onInventoryReceived(item:Item):int
84 if (item.id == this.item.id) {
85 remove();
86 return INTERCEPT_ACTION_USE; // Eat? Drink? Who fucking cares
87 }else
88 return super.onInventoryReceived(item);
91 private function remove():void {
92 InfoScreen.push("<p>Your hunger subsides.</p>");
93 delete host.enchantments[getID()];