package com.cardshifter.api.messages;

import java.util.HashMap;
import java.util.Map;

import com.cardshifter.api.both.ChatMessage;
import com.cardshifter.api.both.InviteRequest;
import com.cardshifter.api.both.InviteResponse;
import com.cardshifter.api.both.PlayerConfigMessage;
import com.cardshifter.api.incoming.LoginMessage;
import com.cardshifter.api.incoming.RequestTargetsMessage;
import com.cardshifter.api.incoming.ServerQueryMessage;
import com.cardshifter.api.incoming.StartGameRequest;
import com.cardshifter.api.incoming.TransformerMessage;
import com.cardshifter.api.incoming.UseAbilityMessage;
import com.cardshifter.api.outgoing.AvailableModsMessage;
import com.cardshifter.api.outgoing.AvailableTargetsMessage;
import com.cardshifter.api.outgoing.CardInfoMessage;
import com.cardshifter.api.outgoing.ClientDisconnectedMessage;
import com.cardshifter.api.outgoing.EntityRemoveMessage;
import com.cardshifter.api.outgoing.GameMessage;
import com.cardshifter.api.outgoing.GameOverMessage;
import com.cardshifter.api.outgoing.NewGameMessage;
import com.cardshifter.api.outgoing.PlayerMessage;
import com.cardshifter.api.outgoing.ResetAvailableActionsMessage;
import com.cardshifter.api.outgoing.ServerErrorMessage;
import com.cardshifter.api.outgoing.UpdateMessage;
import com.cardshifter.api.outgoing.UsableActionMessage;
import com.cardshifter.api.outgoing.UserStatusMessage;
import com.cardshifter.api.outgoing.WaitMessage;
import com.cardshifter.api.outgoing.WelcomeMessage;
import com.cardshifter.api.outgoing.ZoneChangeMessage;
import com.cardshifter.api.outgoing.ZoneMessage;

public class MessageTypeIdResolver {
	
	private static final Map<String, Class<? extends Message>> clazzes = new HashMap<String, Class<? extends Message>>();
	
	static {
		clazzes.put("serial", TransformerMessage.class);
		
		clazzes.put("chat", ChatMessage.class);
		clazzes.put("login", LoginMessage.class);
		clazzes.put("startgame", StartGameRequest.class);
		clazzes.put("use", UseAbilityMessage.class);
		clazzes.put("requestTargets", RequestTargetsMessage.class);
		clazzes.put("zoneChange", ZoneChangeMessage.class);
		clazzes.put("entityRemoved", EntityRemoveMessage.class);
		clazzes.put("disconnect", ClientDisconnectedMessage.class);
		
		clazzes.put("resetActions", ResetAvailableActionsMessage.class);
		clazzes.put("game", GameMessage.class);
		clazzes.put("gameover", GameOverMessage.class);
		clazzes.put("wait", WaitMessage.class);
		clazzes.put("loginresponse", WelcomeMessage.class);
		clazzes.put("newgame", NewGameMessage.class);
		clazzes.put("player", PlayerMessage.class);
		clazzes.put("card", CardInfoMessage.class);
		clazzes.put("zone", ZoneMessage.class);
		clazzes.put("update", UpdateMessage.class);
		clazzes.put("useable", UsableActionMessage.class);
		clazzes.put("targets", AvailableTargetsMessage.class);
		clazzes.put("availableMods", AvailableModsMessage.class);
		
		clazzes.put("inviteRequest", InviteRequest.class);
		clazzes.put("inviteResponse", InviteResponse.class);
		clazzes.put("error", ServerErrorMessage.class);
		clazzes.put("userstatus", UserStatusMessage.class);
		clazzes.put("query", ServerQueryMessage.class);
		clazzes.put("playerconfig", PlayerConfigMessage.class);
	}

    public static Class<? extends Message> get(String key) {
        return clazzes.get(key);
    }
	
}

@@ -1596,177 +1596,701 @@
 e;%0A%0A
-public class MessageTypeIdResolver %7B%0A%09%0A%09private static final Map%3CString, Class%3C? extends Message%3E%3E clazzes = new HashMap%3CString, Class%3C? extends Message%3E%3E();%0A%09%0A%09static %7B
+/**%0A * Message Type ID Resolver.%0A * %3Cp%3E%0A * Resolves all messages' type ID to the correct class corresponding to this particular type.%0A * Please note the use of the names %3Ccode%3Eclazz / clazzes%3C/code%3E in lieu of %3Ccode%3Eclass / classes%3C/code%3E %0A * because %3Ccode%3Eclass%3C/code%3E is a reserved Java keyword.%0A */%0Apublic class MessageTypeIdResolver %7B%0A%09%0A%09/** This value is used to map a String message ID to its corresponding message class */%0A%09private static final Map%3CString, Class%3C? extends Message%3E%3E clazzes = new HashMap%3CString, Class%3C? extends Message%3E%3E();%0A%09%0A%09/** Array used to map this message ID key to its corresponding class */%0A%09static %7B%0A%09%09// Serialize message (used principally for libGDX client)
 %0A%09%09c
@@ -2331,32 +2331,62 @@
 ssage.class);%0A%09%09
+// Incoming messages to server
 %0A%09%09clazzes.put(%22
@@ -2786,32 +2786,64 @@
 ssage.class);%0A%09%09
+// Outgoing messages from server
 %0A%09%09clazzes.put(%22
@@ -3482,16 +3482,54 @@
 ass);%0A%09%09
+// Messages both incoming and outgoing
 %0A%09%09clazz
@@ -3844,21 +3844,55 @@
 ss);%0A%09%7D%0A
-%0A
+  
     
+  /** @return message ID key */%0A%09
 public s
@@ -3940,16 +3940,17 @@
  key) %7B%0A
+%09
         
@@ -3974,18 +3974,15 @@
 t(key);%0A
-    
+%09
 %7D%0A%09%0A%7D%0A

Update MessageTypeIdResolver.java