import jp.osdn.jindolf.parser.content.DecodedContent;
import jp.sfjp.jindolf.data.Avatar;
import jp.sfjp.jindolf.data.Period;
+import jp.sfjp.jindolf.data.Player;
import jp.sfjp.jindolf.data.SysEvent;
import jp.sfjp.jindolf.data.Talk;
import jp.sfjp.jindolf.data.Topic;
private final List<Integer> integerList = new LinkedList<>();
private final List<CharSequence> charseqList =
new LinkedList<>();
+ private final List<Player> playerList = new LinkedList<>();
/**
this.roleList.clear();
this.integerList.clear();
this.charseqList.clear();
+ this.playerList.clear();
return;
}
SeqRange avatarRange)
throws HtmlParseException{
Avatar newAvatar = toAvatar(content, avatarRange);
- this.integerList.add(entryNo);
- this.avatarList.add(newAvatar);
+ Player player = new Player();
+ player.setAvatar(newAvatar);
+ player.setEntryNo(entryNo);
+ this.playerList.add(player);
return;
}
event.addRoleList(this.roleList);
event.addIntegerList(this.integerList);
event.addCharSequenceList(this.charseqList);
+ event.addPlayerList(this.playerList);
this.period.addTopic(event);
package jp.sfjp.jindolf.data.xml;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import jp.osdn.jindolf.parser.content.DecodedContent;
import jp.sfjp.jindolf.data.CoreData;
import jp.sfjp.jindolf.data.Land;
import jp.sfjp.jindolf.data.Period;
+import jp.sfjp.jindolf.data.Player;
import jp.sfjp.jindolf.data.SysEvent;
import jp.sfjp.jindolf.data.Talk;
import jp.sfjp.jindolf.data.Topic;
private Village village;
private Period period;
- private Avatar talkAvatar;
+ private Talk talk;
private int talkNo;
- private TalkType talkType;
- private String messageId;
- private String talkTime;
-
- private SysEventType sysEventType;
+ private SysEvent sysEvent;
private boolean inLine;
private final StringBuilder content = new StringBuilder(250);
this.nsPfx = null;
this.land = null;
this.period = null;
- this.messageId = null;
- this.talkTime = null;
return;
}
String xname = attrValue(atts, "xname");
String time = attrValue(atts, "time");
- this.talkAvatar = this.idAvatarMap.get(avatarId);
- this.talkType = decodeTalkType(type);
- this.messageId = xname;
+ TalkType talkType = decodeTalkType(type);
+ Avatar talkAvatar = this.idAvatarMap.get(avatarId);
+ int hour = decodeHour (time);
+ int minute = decodeMinute(time);
+
+ this.talk = new Talk(
+ this.period,
+ talkType, talkAvatar,
+ 0, xname,
+ hour, minute,
+ ""
+ );
+
this.content.setLength(0);
- this.talkTime = time;
return;
}
*/
private void endTalk(){
int no = 0;
- if(this.talkType == TalkType.PUBLIC){
+ if(this.talk.getTalkType() == TalkType.PUBLIC){
no = ++this.talkNo;
}
- int hour = decodeHour (this.talkTime);
- int minute = decodeMinute(this.talkTime);
-
String dialog = this.content.toString();
+ this.content.setLength(0);
- Talk talk = new Talk(
- this.period,
- this.talkType, this.talkAvatar,
- no, this.messageId,
- hour, minute,
- dialog
- );
-
- this.period.addTopic(talk);
+ this.talk.setTalkNo(no);
+ this.talk.setDialog(dialog);
- this.talkType = null;
- this.talkAvatar = null;
- this.messageId = null;
- this.content.setLength(0);
- this.talkTime = null;
+ this.period.addTopic(this.talk);
return;
}
*
* @param type SysEvent種別
*/
- private void startSysEvent(SysEventType type, Attributes atts){
- this.sysEventType = type;
+ private void startSysEvent(ElemTag tag, Attributes atts){
+ this.sysEvent = new SysEvent();
- if(this.sysEventType == SysEventType.ASSAULT){
- String byWhom = attrValue(atts, "byWhom");
- String xname = attrValue(atts, "xname");
- String time = attrValue(atts, "time");
+ SysEventType type = tag.getSystemEventType();
+ EventFamily eventFamily = type.getEventFamily();
+ this.sysEvent.setSysEventType(type);
+ this.sysEvent.setEventFamily(eventFamily);
- this.talkAvatar = this.idAvatarMap.get(byWhom);
- this.talkType = TalkType.WOLFONLY;
- this.messageId = xname;
- this.talkTime = time;
+ if(this.sysEvent.getSysEventType() == SysEventType.ASSAULT){
+ startAssault(atts);
+ }else{
+ switch(tag){
+ case ONSTAGE:
+ startOnStage(atts);
+ break;
+ default:
+ break;
+ }
}
this.content.setLength(0);
+
return;
}
*
* @return パースしたSysEvent。
*/
- private SysEvent endSysEvent(){
- SysEvent ev = null;
+ private void endSysEvent(){
Topic topic;
- if(this.sysEventType == SysEventType.ASSAULT){
- int hour = decodeHour (this.talkTime);
- int minute = decodeMinute(this.talkTime);
-
- String dialog = this.content.toString();
-
- Talk talk = new Talk(
- this.period,
- this.talkType, this.talkAvatar,
- 0, this.messageId,
- hour, minute,
- dialog );
- topic = talk;
- this.talkType = null;
- this.talkAvatar = null;
- this.talkTime = null;
- this.messageId = null;
+ if(this.sysEvent.getSysEventType() == SysEventType.ASSAULT){
+ endAssault();
+ topic = this.talk;
}else{
- ev = buildSysEvent();
- topic = ev;
+ DecodedContent decoded = new DecodedContent(this.content);
+ this.sysEvent.setContent(decoded);
+ topic = this.sysEvent;
}
this.period.addTopic(topic);
this.content.setLength(0);
- this.sysEventType = null;
- return ev;
+ return;
}
/**
- * SystemEvent 生成共通処理。
+ * assault要素開始の受信。
*
- * <p>イベントファミリ、イベントタイプ、会話テキストが設定される。
+ * @param atts 属性
+ */
+ private void startAssault(Attributes atts){
+ String byWhom = attrValue(atts, "byWhom");
+ String xname = attrValue(atts, "xname");
+ String time = attrValue(atts, "time");
+
+ Avatar talkAvatar = this.idAvatarMap.get(byWhom);
+
+ int hour = decodeHour (time);
+ int minute = decodeMinute(time);
+
+ this.talk = new Talk(
+ this.period,
+ TalkType.WOLFONLY, talkAvatar,
+ 0, xname,
+ hour, minute,
+ ""
+ );
+
+ return;
+ }
+
+ /**
+ * assault要素終了の受信。
+ */
+ private void endAssault(){
+ String dialog = this.content.toString();
+ this.content.setLength(0);
+
+ this.talk.setDialog(dialog);
+
+ return;
+ }
+
+ /**
+ * onStage要素開始の受信。
*
- * @return SystemEvent
+ * @param atts 属性
*/
- private SysEvent buildSysEvent(){
- SysEvent ev = new SysEvent();
+ private void startOnStage(Attributes atts){
+ String entryNo = attrValue(atts, "entryNo");
+ String avatarId = attrValue(atts, "avatarId");
- EventFamily eventFamily = this.sysEventType.getEventFamily();
- ev.setSysEventType(this.sysEventType);
- ev.setEventFamily(eventFamily);
+ Avatar avatar = this.idAvatarMap.get(avatarId);
+ int entry = Integer.parseInt(entryNo);
- DecodedContent dc = new DecodedContent(this.content);
- ev.setContent(dc);
+ Player player = new Player();
+ player.setAvatar(avatar);
+ player.setEntryNo(entry);
- return ev;
+ this.sysEvent.addPlayerList(Collections.singletonList(player));
+
+ return;
}
/**
if(tag == null) return;
if(tag.isSysEventTag()){
- startSysEvent(tag.getSystemEventType(), atts);
+ startSysEvent(tag, atts);
return;
}