-
-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New methods setGameScore and getGameHighScores
- Loading branch information
Showing
4 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
src/main/java/com/pengrad/telegrambot/model/GameHighScore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.pengrad.telegrambot.model; | ||
|
||
/** | ||
* Stas Parshin | ||
* 04 October 2016 | ||
*/ | ||
public class GameHighScore { | ||
|
||
private Integer position; | ||
private User user; | ||
private Integer score; | ||
|
||
public Integer position() { | ||
return position; | ||
} | ||
|
||
public User user() { | ||
return user; | ||
} | ||
|
||
public Integer score() { | ||
return score; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
GameHighScore that = (GameHighScore) o; | ||
|
||
if (!position.equals(that.position)) return false; | ||
if (!user.equals(that.user)) return false; | ||
return score.equals(that.score); | ||
|
||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = position.hashCode(); | ||
result = 31 * result + user.hashCode(); | ||
result = 31 * result + score.hashCode(); | ||
return result; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "GameHighScore{" + | ||
"position=" + position + | ||
", user=" + user + | ||
", score=" + score + | ||
'}'; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/pengrad/telegrambot/request/GetGameHighScores.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.pengrad.telegrambot.request; | ||
|
||
import com.pengrad.telegrambot.response.GetWebhookInfoResponse; | ||
|
||
/** | ||
* Stas Parshin | ||
* 04 October 2016 | ||
*/ | ||
public class GetGameHighScores extends BaseRequest<GetGameHighScores, GetWebhookInfoResponse> { | ||
|
||
public GetGameHighScores(int userId, Object chatId, int messageId) { | ||
super(GetWebhookInfoResponse.class); | ||
add("user_id", userId).add("chat_id", chatId).add("message_id", messageId); | ||
} | ||
|
||
public GetGameHighScores(int userId, String inlineMessageId) { | ||
super(GetWebhookInfoResponse.class); | ||
add("user_id", userId).add("inline_message_id", inlineMessageId); | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/pengrad/telegrambot/request/SetGameScore.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.pengrad.telegrambot.request; | ||
|
||
import com.pengrad.telegrambot.response.BaseResponse; | ||
import com.pengrad.telegrambot.response.SendResponse; | ||
|
||
/** | ||
* Stas Parshin | ||
* 03 October 2016 | ||
*/ | ||
public class SetGameScore extends BaseRequest<SetGameScore, BaseResponse> { | ||
|
||
public SetGameScore(int userId, int score, Object chatId, int messageId) { | ||
super(SendResponse.class); | ||
add("user_id", userId).add("score", score).add("chat_id", chatId).add("message_id", messageId); | ||
} | ||
|
||
public SetGameScore(int userId, int score, String inlineMessageId) { | ||
super(SendResponse.class); | ||
add("user_id", userId).add("score", score).add("inline_message_id", inlineMessageId); | ||
} | ||
|
||
public SetGameScore editMessage(boolean edit_message) { | ||
return add("edit_message", edit_message); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/pengrad/telegrambot/response/GetGameHighScoresResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.pengrad.telegrambot.response; | ||
|
||
import com.pengrad.telegrambot.model.GameHighScore; | ||
|
||
import java.util.Arrays; | ||
|
||
/** | ||
* Stas Parshin | ||
* 04 October 2016 | ||
*/ | ||
public class GetGameHighScoresResponse { | ||
|
||
private GameHighScore[] result; | ||
|
||
public GameHighScore[] result() { | ||
return result; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "GetGameHighScoresResponse{" + | ||
"result=" + Arrays.toString(result) + | ||
'}'; | ||
} | ||
} |