package com.nhn.example.game;

import com.nhn.gameanvil.game.GameAnvilRoom;
import com.nhn.gameanvil.node.game.IRoom;
import com.nhn.gameanvil.node.game.context.IRoomContext;
import com.nhn.gameanvil.node.game.data.MatchCancelReason;
import com.nhn.gameanvil.packet.IPayload;
import com.nhn.gameanvil.serializer.ITimerHandlerTransferPack;
import com.nhn.gameanvil.serializer.ITransferPack;

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

@GameAnvilRoom(
        gameServiceName = "SCENARIO_SERVICE",
        gameType = "SCENARIO_ROOM",
        useChannelInfo = false
)
public class GameRoom implements IRoom<GameUser> {
    private IRoomContext roomContext;
    private List<GameUser> users;

    public List<GameUser> getUsers() {
        return users;
    }

    @Override
    public void onCreate(IRoomContext<GameUser> roomContext) {
        this.roomContext = roomContext;
        users = new ArrayList<>();
    }

    @Override
    public void onInit() {

    }

    @Override
    public void onDestroy() {

    }

    @Override
    public boolean onCreateRoom(GameUser user, IPayload payload, IPayload outPayload) {
        boolean isSuccess = true;
        users.add(user);
        return isSuccess;
    }

    @Override
    public boolean onJoinRoom(GameUser user, IPayload payload, IPayload outPayload) {
        boolean isSuccess = true;
        users.add(user);
        return isSuccess;
    }

    @Override
    public boolean canLeaveRoom(GameUser user, IPayload payload, IPayload outPayload) {
        return true;
    }

    @Override
    public void onLeaveRoom(GameUser user) {
        users.remove(user);
    }

    @Override
    public void onAfterLeaveRoom() {

    }

    @Override
    public void onRejoinRoom(GameUser user, IPayload payload) {

    }

    @Override
    public void onTransferOut(ITransferPack transferPack) {

    }

    @Override
    public void onTransferIn(List<GameUser> list, ITransferPack transferPack, ITimerHandlerTransferPack timerHandlerTransferPack) {

    }

    @Override
    public void onAfterTransferIn() {

    }

    @Override
    public void onPause() {

    }

    @Override
    public void onResume() {

    }

    @Override
    public boolean onMatchParty(String roomType, String matchingGroup, GameUser user, IPayload payload, IPayload outPayload) {
        boolean isSuccess = true;
        return isSuccess;
    }

    @Override
    public void onMatchPartyCancel(MatchCancelReason matchCancelReason) {

    }

    @Override
    public void onForceMatchRoomUnregistered(MatchCancelReason matchCancelReason) {

    }

    @Override
    public boolean canTransfer() {
        return true;
    }
}
