Fix hair, dick around with new game screen.
[18plus-7leafadventure.git] / src / org / sevenchan / dongs / enchantment / Enchantment.as
blob1eaa7d7ae83a2cd3e87c805cbbc2b1e6c86db2a3
1 package org.sevenchan.dongs.enchantment
3 import org.sevenchan.dongs.Creature;
4 import flash.utils.getQualifiedClassName;
5 import org.sevenchan.dongs.Item;
6 import org.sevenchan.dongs.screens.CombatScreen;
8 /**
9 * MAGICK
10 * @author Harbinger
12 public class Enchantment
14 /**
15 * Cancel being added to new host.
17 public var cancelAddition:Boolean = false;
19 public function Enchantment()
24 /**
25 * When first added to some poor sap's Enchantments
27 public function onInit(newHost:Creature):String
29 return "";
32 /**
33 * Unique name for every enchantment (so the enchantment can remove itself).
34 * @return
36 public function getID():String
38 throw new Error("FATAL ERROR: " + getQualifiedClassName(this) + " does not specify a custom getID()!");
39 return "";
42 /**
43 * Do stuff after host wins/loses.
44 * @param hostWon
45 * @param other
47 public function onCombatComplete(hostWon:Boolean, other:Creature):void
52 /**
53 * Do stuff when combat begins
54 * @param other
56 public function onCombatInit(other:Creature):void
61 /**
62 * Do stuff when it's my host's turn
63 * @param other
64 * @return Skip turn?
66 public function onMyCombatTurn(screen:CombatScreen,other:Creature):Boolean
68 return false;
71 /**
72 * Can the player attack?
73 * @param player
74 * @param other
75 * @return
77 public function canAttack(player:Creature, other:Creature):Boolean
79 return true;
82 /**
83 * Can the player run?
84 * @param player
85 * @param other
86 * @return
88 public function canRun(player:Creature, other:Creature):Boolean
90 return true;
93 /**
94 * Do stuff after each screen update.
95 * @return
97 public function onScreenUpdate():void
101 public static const INTERCEPT_ACTION_NONE:int = -1;
102 public static const INTERCEPT_ACTION_USE:int = 0;
103 public static const INTERCEPT_ACTION_TOSS:int = 1;
105 * Inventory received
106 * @param item
107 * @return intercept action
109 public function onInventoryReceived(item:Item):int { return INTERCEPT_ACTION_NONE; }
111 * Inventory received
112 * @param item
113 * @return intercept action
115 public function onInventorySent(item:Item):int { return INTERCEPT_ACTION_NONE; }
117 public function getName():String
119 trace("ERROR: " + getQualifiedClassName(this) + " does not specify a custom getName()!");
120 return getID() + " [WIP?]";
123 public function getDescr():String
125 trace("ERROR: " + getQualifiedClassName(this) + " does not specify a custom getDescr()!");
126 return "???";
129 public static function isLockedOut(subj:Creature):Boolean
131 return subj.hasEnchantment("paralyze") || subj.hasEnchantment("hunger");
133 public static function canAttack(subj:Creature,combatant:Creature):Boolean
135 for each(var e:Enchantment in subj.enchantments)
137 if (!e.canAttack(subj, combatant))
138 return false;
140 return true;
142 public static function canRun(subj:Creature,combatant:Creature):Boolean
144 for each(var e:Enchantment in subj.enchantments)
146 if (!e.canRun(subj, combatant))
147 return false;
149 return true;
152 public static function getLockoutEffectText(subj:Creature):String
154 if (subj.hasEnchantment("paralyze"))
155 return "PARALYZED";
156 if (subj.hasEnchantment("hunger"))
157 return "HUNGRY";
158 return "IDKLOL";