Newer
Older
IrisServer / src / main / java / com / ntlab / irisserver / entities / Turn.java
package com.ntlab.irisserver.entities;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.ArrayList;
import java.util.List;
import java.util.Iterator;

public class Turn {

    @JsonProperty("hint")
    private String hint;

    @JsonProperty("team")
    private String team;

    @JsonProperty("max")
    private int max;

    @JsonProperty("turnstate")
    private int turnstate;

    @JsonProperty("gamestate")
    private int gamestate;//0:turn継続, 1:turn終了, 2:game終了

    private List<Member> questions[] = new ArrayList[16]; //<cno, List<Menber>>

    private List<Integer> openlist = new ArrayList<>();

    //コンストラクタ

    public Turn(){
        max = -1;
        turnstate = 0;
        gamestate = 0;
    }

    //---------------------------------------------------------
    //セッター

    public void setHint(String hint) {this.hint = hint;}

    public void setTeam(String team) {this.team = team;}

    public void setMax(int max) {this.max = max;}

    public void setTurnstate(int turnstate) {this.turnstate = turnstate;}

    public void setGamestate(int gamestate) {this.gamestate = gamestate;}

    //---------------------------------------------------------
    //ゲッター

    public String getHint() {return hint;}

    public String getTeam() {return team;}

    public int getMax() {return max;}

    public List<Integer> getOpenListAll() {return openlist;} //リストそのものを返す。

    public List<Member>[] getQuestionsList() {return questions;}

    public int getTurnstate() {return turnstate;}

    public int getGamestate() {return gamestate;}

    //---------------------------------------------------------
    //questions操作

    public List<Member> getQuestions(int cno){return questions[cno];}

    public void addQuestions(int cno, Member m){questions[cno].add(m);}

    public void delieteQuestions(int cno, Member m){
        List<Member> list = questions[cno];
        for(Iterator it = list.iterator(); it.hasNext();){
            Member member = (Member) it.next();
            if(member.getNickname() == m.getNickname()){
                it.remove();
                break;
            }
        }

    }

    public int sizeQuestions(int cno){return questions[cno].size();}

    //openlist操作

    public Integer getOpenListSolo(int num){return openlist.get(num);}

    public void addOpenList(Integer cno){openlist.add(cno);}

    public void delieteOpenList(int num){openlist.remove(num);}

    public int sizeOpenList(){return openlist.size();}


}