Initial commit (r9)
[18plus-7leafadventure.git] / src / org / sevenchan / dongs / creature / Player.as
blobda2261550b2d5735bfc3f90d05df8aa6ce72d3af
1 package org.sevenchan.dongs.creature
3 import com.adobe.serialization.json.*;
4 import flash.events.Event;
5 import flash.net.*;
6 import org.sevenchan.dongs.ability.Instawin;
7 import org.sevenchan.dongs.bodyparts.*;
8 import org.sevenchan.dongs.*;
9 import flash.utils.*;
10 import org.sevenchan.dongs.enchantment.Enchantment;
11 import org.sevenchan.dongs.screens.CombatScreen;
12 /**
13 * ...
14 * @author N3X15
16 public class Player extends Creature
18 private var f:FileReference = new FileReference();
19 private var baseType:Creature = new Human();
20 private var saveFile:FileReference = null;
21 private var waitingForLoad:Boolean = false;
22 private var cancelled:Boolean = false;
23 public var currentTown:Town = Town.knownTowns["barn"];
24 public var main:Main;
26 public function Player(main:Main)
28 this.main = main;
29 trace("Player.init()");
32 public function changeTo(t:Creature):void {
33 var tmp:Creature = baseType;
34 baseType = t;
35 baseType._speed = tmp._speed;
36 baseType._strength = tmp._strength;
37 baseType.abilities = tmp.abilities;
38 baseType.enchantments = tmp.enchantments;
39 baseType.explored = tmp.explored;
40 baseType.gender = tmp.gender;
41 baseType.gold = tmp.gold;
42 baseType.height = tmp.height;
43 baseType.HP = tmp.maxHP;
44 baseType.ownName = tmp.ownName;
45 baseType.sensitivity = tmp.sensitivity;
46 baseType.sexualPreference = tmp.sexualPreference;
47 baseType.inventory = tmp.inventory;
49 baseType.performConversion(tmp);
54 override public function getExplored(loc:String):Boolean {
55 for (var i:int = 0; i < baseType.explored.length; i++) {
56 if (baseType.explored[i] == loc)
57 return true;
59 return false;
62 override public function setExplored(loc:String):void {
63 if (getExplored(loc)) return;
64 baseType.explored.push(loc);
67 public function save():void {
68 var f:FileReference = new FileReference();
69 var ba:ByteArray = new ByteArray();
70 ba.writeObject(
72 currentTown: currentTown.ID,
73 body: baseType
76 f.save(ba, "save.dat");
79 public function load():Boolean {
81 waitingForLoad = true;
82 f.addEventListener(Event.SELECT, onFileSelected);
83 f.addEventListener(Event.CANCEL, onFileCancelled);
84 if (!f.browse([new FileFilter("Saves","*.dat")]))
85 return false;
86 return true;
89 private function onFileSelected(e:Event):void {
90 f.addEventListener(Event.COMPLETE, onFileLoaded);
91 f.load();
94 private function onFileLoaded(e:Event):void {
95 var saveData:Object = f.data.readObject();
96 this.currentTown = Town.knownTowns[saveData.currentTown];
97 this.baseType = saveData.body;
98 main.onPlayerLoaded();
101 private function onFileCancelled(e:Event):void {
104 override public function initialGenderSetup():void
106 baseType.initialGenderSetup();
109 override public function yourMove(cs:CombatScreen, ply:Creature):void
113 public override function getDescription():String {
114 var descr:String = "<h2>Appearance</h2>";
115 // You, Charles Cockhammer, are a gay human male of average height and build. You also possess a long, flowing mane of golden hair,
116 // which contrasts nicely with your blue eyes and light skin.
118 // In the equipment department, you're not too odd. You have two human testicles swinging between your legs, paired with
119 // a single, 5.5" human schlong. Your breasts are flat, but well-sculpted human pecs, and you have a standard-issue male
120 // ass with a standard-issue virgin male asshole between its buns. You've got two human arms, two human legs.
122 // In other words, you're an average human, which probably won't last long down here.
124 descr += "<p>You, " + baseType.ownName + ", are " + Utils.A(baseType.sexualPreference.label) + " " + baseType.gender.label + " " + baseType.getTypeName() + " " + baseType.build.getDescription()
125 +" You also possess " + baseType.hair.getDescription();
127 if (baseType.hair == Hair.BALD)
128 descr += ", your glistening scalp distracting from your ";
129 else
130 descr += ", which constrasts nicely with your ";
131 if(baseType.eyes.length == 0)
132 descr += " complete lack of eyes (<b>and resulting blindness</b>)";
133 else
134 descr += baseType.getEyesDescr();
136 descr += " and " + baseType.skin.getDescr(0, this);
137 descr += "</p>";
139 descr += "<p>In the equipment department, ";
140 //if (baseType.customized)
141 // descr += "you're a bit different from the average bear. ";
142 //else
143 descr += "you're not too odd, compared to other "+baseType.getTypeName()+"s. ";
144 var haveBalls:Boolean = (baseType.balls.length > 0);
145 var haveDicks:Boolean = (baseType.dicks.length > 0);
146 var haveVags:Boolean = (baseType.vaginas.length > 0);
147 if (haveBalls && haveDicks)
148 descr += "You have " + baseType.getTesticleDescr() + " swinging between your legs, paired with " + baseType.getDickDescr() + ".";
149 if (!haveBalls && haveDicks)
150 descr += "No testicles rub between your thighs when you walk, but you do have " + baseType.getDickDescr() + ".";
151 if (haveBalls && !haveDicks)
152 descr += "You don't have a dick, but you do have " + baseType.getTesticleDescr() + ". <b>Because of a lack of an outlet for semen, you cannot masturbate, so your balls fill with semen, out of control.</b>";
154 if (haveVags)
155 descr += "Your body possesses " + baseType.getVagDescr() + ".";
157 if (!haveBalls && !haveDicks && !haveVags)
158 descr += "You don't have any sexual organs, so you can't masturbate. On the bright side, you won't get horny, either.";
161 if (baseType.breasts.length > 0)
162 descr += "You have " + baseType.getBreastDescr() + ", and you wear ";
163 else
164 descr += "You don't have any breasts, but you do have ";
165 descr += baseType.getAssDescr() + ".";
167 if (baseType.arms.length > 0)
168 descr += "You have "+baseType.getArmsDescr()+", ";
169 else
170 descr += "You don't have any arms (<b>and therefore can't attack</b>), ";
172 if (baseType.legs.length > 0) {
173 if (baseType.arms.length == 0)
174 descr += "but you DO have ";
175 else
176 descr += "and ";
177 descr += baseType.getLegsDescr()+".";
178 } else
179 descr += "and no legs (<b>so you can't dodge attacks</b>).";
180 descr += "</p>";
182 return baseType.gender.doReplace(descr);
185 override public function getTypeName():String
187 return baseType.getTypeName();
190 override public function levelUp(firstTime:Boolean=false):void
192 baseType.levelUp(firstTime);
195 override public function recalcStrength():void
197 baseType.recalcStrength();
200 public function setBaseType(base:Creature):void {
201 baseType = base;
202 baseType.abilities["instawin"] = new Instawin();
206 override public function hasEnchantment(name:String):Boolean {
207 return baseType.hasEnchantment(name);
210 override public function addEnchantment(ench:Enchantment):String
212 return baseType.addEnchantment(ench);
214 override public function notifyEnchantments(e:*):Boolean
216 return baseType.notifyEnchantments(e);
219 override public function get wings():Array { return baseType._wings; }
220 override public function set wings(wings:Array):void { baseType._wings=wings;
221 customized = true; }
223 override public function get vaginas():Array { return baseType._vaginas; }
224 override public function set vaginas(balls:Array):void { baseType._vaginas=balls;
225 customized = true; }
227 override public function get dicks():Array { return baseType._dicks; }
228 override public function set dicks(balls:Array):void { baseType._dicks=balls;
229 customized = true; }
231 public override function get strength():int { return baseType.strength; }
232 public override function set strength(value:int):void { baseType.strength = value; }
234 public override function get speed():uint { return baseType.speed; }
235 public override function set speed(value:uint):void { baseType.speed=value; }
237 public override function get balls():Array { return baseType.balls; }
238 public override function set balls(balls:Array):void { baseType.balls=balls; }
240 public override function get intellect():uint { return baseType.intellect; }
241 public override function set intellect(value:uint):void { baseType.intellect = value; }
243 public override function get arms():Array { return baseType.arms; }
244 public override function set arms(arr:Array):void { baseType.arms = arr; }
246 public override function get legs():Array { return baseType.legs; }
247 public override function set legs(arr:Array):void{ baseType.legs=arr; }
249 public override function get abilities():Object { return baseType.abilities; }
250 public override function set abilities(arr:Object):void{ baseType.abilities=arr; }
252 public override function get gender():Gender{ return baseType.gender; }
253 public override function set gender(arr:Gender):void { baseType.gender = arr; }
255 public override function get level():int{ return baseType.level; }
257 public override function get HP():int{ return baseType.HP; }
258 public override function get maxHP():int{ return baseType.maxHP; }
259 public override function set HP(value:int):void { baseType.HP = value; main.refreshStats(); }
261 public override function get XP():int{ return baseType.XP; }
262 public override function get maxXP():int { trace("maxXP", baseType.maxXP); return baseType.maxXP; }
263 public override function set XP(value:int):void { baseType.XP = value; main.refreshStats(); }