summaryrefslogtreecommitdiff
path: root/NET/worlds/console/BBDroneBitmapCommand.java
blob: 48e241255c1dce2c5adb9c7629d55de4b318b0a1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package NET.worlds.console;

import NET.worlds.network.URL;
import NET.worlds.scape.Drone;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

public class BBDroneBitmapCommand extends BlackBoxCommand {
   private String name;
   private String bitmap;

   public BBDroneBitmapCommand(String pName, String pBitmap) {
      this();
      this.name = new String(pName);
      this.bitmap = new String(pBitmap);
   }

   public BBDroneBitmapCommand() {
      this.commandType = 7;
   }

   @Override
   public boolean execute() {
      Drone id = ArmyOfZombies.instance().get(this.name);
      if (id != null) {
         Drone newDrone = id.handleVAR_BITMAP(this.bitmap);
         ArmyOfZombies.instance().replaceZombie(this.name, newDrone);
      } else if (this.name.equals("@Pilot")) {
         Console c = Console.getActive();
         if (c != null) {
            c.setAvatar(URL.make(this.bitmap));
         }
      } else {
         System.out.println("Couldn't find drone " + this.name + " for bitmap command.");
      }

      this.doCallback(true);
      return true;
   }

   @Override
   public void save(DataOutputStream dos) throws IOException {
      super.save(dos);
      dos.writeUTF(this.name);
      dos.writeUTF(this.bitmap);
   }

   @Override
   public void load(DataInputStream dis) throws IOException {
      super.load(dis);
      this.name = new String(dis.readUTF());
      this.bitmap = new String(dis.readUTF());
   }
}