1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package net.sf.magicproject.xml.tbs;
22
23 import java.io.IOException;
24 import java.io.OutputStream;
25 import java.util.Iterator;
26
27 import net.sf.magicproject.clickable.ability.AbilityType;
28 import net.sf.magicproject.xml.XmlEvent;
29 import net.sf.magicproject.xml.XmlParser;
30 import net.sf.magicproject.xml.XmlTbs;
31 import net.sf.magicproject.xml.XmlToMDB;
32 import net.sf.magicproject.xml.XmlTools;
33
34 /***
35 * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
36 * @since 0.82
37 */
38 public class Systemability implements XmlToMDB {
39
40 /***
41 * <ul>
42 * Structure of stream : Data[size]
43 * <li>ability [Ability]</li>
44 * <li>event [Event]</li>
45 * <li>cost [Action[]]</li>
46 * </ul>
47 *
48 * @param node
49 * the XML card structure
50 * @param out
51 * outputstream where the card structure will be saved
52 * @return the amount of written action in the output.
53 * @throws IOException
54 * error while writting.
55 * @see net.sf.magicproject.clickable.ability.Priority
56 */
57 public final int buildMdb(XmlParser.Node node, OutputStream out)
58 throws IOException {
59
60 Ability.buildAbility(AbilityType.SYSTEM_ABILITY, node, out);
61
62
63 node.addAttribute(new XmlParser.Attribute("zone", "play"));
64 Iterator<?> it = node.iterator();
65 XmlTools.defaultOnMeTag = false;
66 while (it.hasNext()) {
67 Object obj = it.next();
68 if (obj instanceof XmlParser.Node) {
69 XmlParser.Node child = (XmlParser.Node) obj;
70 if ("text".equals(child.getTag())) {
71 System.out.println("text element in ability is not yet implement");
72 } else {
73 XmlEvent.getEvent(child.getTag()).buildMdb(child, out);
74 break;
75 }
76 }
77 }
78
79
80 XmlTbs.currentInEffect = true;
81 XmlTbs.writeActionList(node.get("effects"), out);
82 return 0;
83 }
84
85 }