Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/Cardshifter/Cardshifter
Browse files Browse the repository at this point in the history
…into ecs-module-support
  • Loading branch information
skiwi2 committed Oct 6, 2014
2 parents f079098 + 2c90f59 commit a82646a
Show file tree
Hide file tree
Showing 125 changed files with 3,762 additions and 1,385 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ nbactions.xml

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm

/*.iml
*.iml

## Directory-based project format:
.idea/
Expand Down
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,23 @@ We would like everyone to follow the following guidelines:
Platform
--------

Currently we plan to support version Java 8u20 and above.
Currently we plan to support version Java 8u20 and above.

Playing the game
----------------

To play the game, [download the latest release](https://github.com/Cardshifter/Cardshifter/releases). Start the client jar using `java -jar cardshifter-fx-<version>.jar`.

There is a server running at `dwarftowers.com` port `4242` that you may connect to.

Develop another client
----------------------

If you want to help develop another client, [download the latest server release](https://github.com/Cardshifter/Cardshifter/releases). Start the server using `java -jar cardshifter-server-<version>.jar`.

All messages sent between client and server are using JSON format. The available messages can be found [here](https://github.com/Cardshifter/Cardshifter/tree/client-server/cardshifter-api/src/main/java/com/cardshifter/api).

For example, to send a [`LoginMessage`](https://github.com/Cardshifter/Cardshifter/blob/client-server/cardshifter-api/src/main/java/com/cardshifter/api/incoming/LoginMessage.java) pass the following JSON: `{ "command": "login", "username": "example" }`.

To send a request for starting a game, use [`StartGameRequest`](https://github.com/Cardshifter/Cardshifter/blob/client-server/cardshifter-api/src/main/java/com/cardshifter/api/incoming/StartGameRequest.java) which can be sent as JSON like this: `{ "command": "startgame", "opponent": 1, "gameType": "VANILLA" }` (currently "VANILLA" is the only supported game type).

10 changes: 0 additions & 10 deletions cardshifter-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,6 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>analyze-compile</id>
<phase>compile</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.cardshifter.api;

public class CardshifterConstants {

public static final String VANILLA = "VANILLA";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.cardshifter.api.both;

import com.cardshifter.api.messages.Message;
import com.fasterxml.jackson.annotation.JsonCreator;


public class ChatMessage extends Message {

private final int chatId;
private final String message;
private final String from;

@JsonCreator
ChatMessage() {
this(0, "", "");
}

public ChatMessage(int chatId, String from, String message) {
super("chat");
this.chatId = chatId;
this.from = from;
this.message = message;
}

public int getChatId() {
return chatId;
}

public String getFrom() {
return from;
}

public String getMessage() {
return message;
}

@Override
public String toString() {
return "ChatMessage [chatId=" + chatId + ", message=" + message
+ ", from=" + from + "]";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.cardshifter.api.both;

import com.cardshifter.api.messages.Message;

public class InviteRequest extends Message {

private final int id;
private final String name;

InviteRequest() {
this(0, "");
}
public InviteRequest(int id, String name) {
super("inviteRequest");
this.id = id;
this.name = name;
}

public int getId() {
return id;
}

public String getName() {
return name;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.cardshifter.api.both;

import com.cardshifter.api.messages.Message;

public class InviteResponse extends Message {

private final int inviteId;
private final boolean accepted;

InviteResponse() {
this(0, false);
}

public InviteResponse(int inviteId, boolean accepted) {
super("inviteResponse");
this.inviteId = inviteId;
this.accepted = accepted;
}

public int getInviteId() {
return inviteId;
}

public boolean isAccepted() {
return accepted;
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,19 @@

public class LoginMessage extends Message {

private String username;
private final String username;

LoginMessage() {
super("login");
this("");
}

public LoginMessage(String username) {
this();
super("login");
this.username = username;
}

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.cardshifter.api.incoming;

import com.cardshifter.api.messages.Message;

public class ServerQueryMessage extends Message {

public enum Request {
USERS;
}

private final Request request;

ServerQueryMessage() {
this(Request.USERS);
}
public ServerQueryMessage(Request request) {
super("query");
this.request = request;
}

public Request getRequest() {
return request;
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
package com.cardshifter.api.incoming;

import com.cardshifter.api.messages.Message;
import com.fasterxml.jackson.annotation.JsonCreator;

public class StartGameRequest extends Message {

public StartGameRequest() {
private final int opponent;
private final String gameType;

@JsonCreator
StartGameRequest() {
this(-1, "");
}

public StartGameRequest(int opponent, String gameType) {
super("startgame");
this.opponent = opponent;
this.gameType = gameType;
}

public int getOpponent() {
return opponent;
}

public String getGameType() {
return gameType;
}

}
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
package com.cardshifter.api.incoming;

import java.util.Arrays;

import com.cardshifter.api.abstr.CardMessage;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;


public class UseAbilityMessage extends CardMessage {

private final int id;
private final String action;
private final int gameId;
private final int target;
private final int[] targets;

@JsonCreator
public UseAbilityMessage(@JsonProperty("gameId") int gameId, @JsonProperty("id") int id,
@JsonProperty("action") String action, @JsonProperty("target") int target) {
UseAbilityMessage() {
this(0, 0, "", new int[]{});
}
public UseAbilityMessage(int gameId, int id, String action, int[] targets) {
super("use");
this.id = id;
this.action = action;
this.gameId = gameId;
this.target = target;
this.targets = Arrays.copyOf(targets, targets.length);
}

public UseAbilityMessage(int gameid, int entity, String action, int target) {
this(gameid, entity, action, new int[]{ target });
}

public String getAction() {
return action;
}
Expand All @@ -34,8 +41,14 @@ public int getGameId() {
return gameId;
}

public int getTarget() {
return target;
public int[] getTargets() {
return Arrays.copyOf(targets, targets.length);
}

@Override
public String toString() {
return "UseAbilityMessage [id=" + id + ", action=" + action
+ ", gameId=" + gameId + ", targets=" + Arrays.toString(targets) + "]";
}

}

0 comments on commit a82646a

Please sign in to comment.