Adding post-game feedback prompt for playtest formats

Imported the post-game popup from the `playtest` branch.  Added an `isPlaytest` field to the format definition and keyed the popup message to only be triggered if the format is for a playtest mode.
This commit is contained in:
Christian 'ketura' McCarty
2021-03-28 00:59:16 -05:00
parent 934408755c
commit 440ea45c95
8 changed files with 62 additions and 13 deletions

View File

@@ -63,7 +63,7 @@
$("#latestNews").append(
"If you find any problems with specific card or rules in general, please report it on TLHH forum - <a target='_blank' href='http://lotrtcgwiki.com/forums/index.php/topic,7592.0.html'>Report a bug</a>, please include game replay link.");
chat = new ChatBoxUI("Game Hall", $("#chat"), "/gemp-lotr-server", true, null, false, true);
chat = new ChatBoxUI("Game Hall", $("#chat"), "/gemp-lotr-server", true, null, false, true, null);
chat.setBounds(2, 2, 780 - 4, 200 - 4);
chat.showTimestamps = true;

View File

@@ -21,11 +21,14 @@ var ChatBoxUI = Class.extend({
lockChat:false,
stopUpdates: false,
dialogListener: null,
init:function (name, div, url, showList, playerListener, showHideSystemButton, showLockButton) {
init:function (name, div, url, showList, playerListener, showHideSystemButton, showLockButton, displayChatListener) {
var that = this;
this.hiddenClasses = new Array();
this.playerListener = playerListener;
this.dialogListener = displayChatListener,
this.name = name;
this.div = div;
this.communication = new GempLotrCommunication(url, function (xhr, ajaxOptions, thrownError) {
@@ -149,6 +152,19 @@ var ChatBoxUI = Class.extend({
this.chatTalkDiv.css({ position:"absolute", left:x + talkBoxPadding + "px", top:y - 2 * talkBoxPadding + (height - this.talkBoxHeight) + "px", width:width - 3 * talkBoxPadding - leftTextBoxPadding, height:this.talkBoxHeight });
}
},
checkForEnd:function (message, msgClass) {
// if(msgClass != "systemMessage")
// {
// return;
// }
if(message.includes("Thank you for playtesting!")) {
if (this.dialogListener != null) {
this.dialogListener("Give us feedback!", message);
}
}
},
appendMessage:function (message, msgClass) {
if (msgClass == undefined)
@@ -166,6 +182,8 @@ var ChatBoxUI = Class.extend({
}
if (!this.lockChat)
this.chatMessagesDiv.prop({ scrollTop:this.chatMessagesDiv.prop("scrollHeight") });
this.checkForEnd(message, msgClass);
},
monthNames:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],

View File

@@ -510,9 +510,20 @@ var GempLotrGameUI = Class.extend({
$("a[href='#playersInRoomBox']").html("Players(" + players.length + ")");
$("#playersInRoomBox").html(val);
};
var displayChatListener = function(title, message) {
var dialog = $("<div></div>").dialog({
title: title,
resizable: true,
height: 200,
modal: true,
buttons: {}
}).html(message);
}
var chatRoomName = (this.replayMode ? null : ("Game" + getUrlParam("gameId")));
this.chatBox = new ChatBoxUI(chatRoomName, $("#chatBox"), this.communication.url, false, playerListener, false, true);
this.chatBox = new ChatBoxUI(chatRoomName, $("#chatBox"), this.communication.url, false, playerListener, false, true, displayChatListener);
this.chatBox.chatUpdateInterval = 3000;
if (!this.spectatorMode && !this.replayMode) {

View File

@@ -18,6 +18,8 @@ public interface LotroFormat {
public boolean winOnControlling5Sites();
public boolean isPlaytest();
public String getName();
public void validateCard(String cardId) throws DeckInvalidException;

View File

@@ -49,7 +49,7 @@ public class GameRecorder {
return new InflaterInputStream(new FileInputStream(file));
}
public GameRecordingInProgress recordGame(LotroGameMediator lotroGame, final String formatName, final String tournament, final Map<String, String> deckNames) {
public GameRecordingInProgress recordGame(LotroGameMediator lotroGame, LotroFormat format, final String tournament, final Map<String, String> deckNames) {
final Date startData = new Date();
final Map<String, GameCommunicationChannel> recordingChannels = new HashMap<String, GameCommunicationChannel>();
for (String playerId : lotroGame.getPlayersPlaying()) {
@@ -58,17 +58,24 @@ public class GameRecorder {
recordingChannels.put(playerId, recordChannel);
}
return new GameRecordingInProgress() {
@Override
public void finishRecording(String winner, String winReason, String loser, String loseReason) {
Map<String, String> playerRecordingId = saveRecordedChannels(recordingChannels);
_gameHistoryService.addGameHistory(winner, loser, winReason, loseReason, playerRecordingId.get(winner), playerRecordingId.get(loser), formatName, tournament, deckNames.get(winner), deckNames.get(loser), startData, new Date());
return (winner, winReason, loser, loseReason) -> {
Map<String, String> playerRecordingId = saveRecordedChannels(recordingChannels);
_gameHistoryService.addGameHistory(winner, loser, winReason, loseReason, playerRecordingId.get(winner), playerRecordingId.get(loser), format.getName(), tournament, deckNames.get(winner), deckNames.get(loser), startData, new Date());
if(format.isPlaytest())
{
String url = "https://docs.google.com/forms/d/e/1FAIpQLSdKJrCmjoyUqDTusDcpNoWAmvkGdzQqTxWGpdNIFX9biCee-A/viewform?usp=pp_url&entry.1592109986=";
String winnerURL = "https://play.lotrtcgpc.net/gemp-lotr/game.html%3FreplayId%3D" + winner + "$" + playerRecordingId.get(winner);
String loserURL = "https://play.lotrtcgpc.net/gemp-lotr/game.html%3FreplayId%3D" + loser + "$" + playerRecordingId.get(loser);
url += winnerURL + "%20" + loserURL;
lotroGame.sendMessageToPlayers("Thank you for playtesting! If you have any feedback, bugs, or other issues to report about this match, <a href= '" + url + "'>please do so using this form.</a>");
}
};
}
public interface GameRecordingInProgress {
public void finishRecording(String winner, String winReason, String loser, String loseReason);
void finishRecording(String winner, String winReason, String loser, String loseReason);
}
private File getRecordingFile(String playerId, String gameId) {

View File

@@ -128,13 +128,14 @@ public class LotroServer extends AbstractServer {
lotroGameMediator.sendMessageToPlayers("Players in the game are: " + players.toString());
final GameRecorder.GameRecordingInProgress gameRecordingInProgress = _gameRecorder.recordGame(lotroGameMediator, gameSettings.getLotroFormat().getName(), tournamentName, deckNames);
final GameRecorder.GameRecordingInProgress gameRecordingInProgress = _gameRecorder.recordGame(lotroGameMediator, gameSettings.getLotroFormat(), tournamentName, deckNames);
lotroGameMediator.addGameResultListener(
new GameResultListener() {
@Override
public void gameFinished(String winnerPlayerId, String winReason, Map<String, String> loserPlayerIdsWithReasons) {
final Map.Entry<String, String> loserEntry = loserPlayerIdsWithReasons.entrySet().iterator().next();
gameRecordingInProgress.finishRecording(winnerPlayerId, winReason, loserEntry.getKey(), loserEntry.getValue());
}

View File

@@ -40,6 +40,7 @@ public class DefaultLotroFormat implements LotroFormat {
private List<Integer> _validSets = new ArrayList<Integer>();
private List<String> _restrictedCardNames = new ArrayList<String>();
private String _surveyUrl;
private boolean _isPlaytest;
//Additional Hobbit Draft parameters
private List<String> _limit2Cards = new ArrayList<String>();
@@ -49,7 +50,7 @@ public class DefaultLotroFormat implements LotroFormat {
LotroCardBlueprintLibrary library, String name, String surveyUrl,
SitesBlock siteBlock,
boolean validateShadowFPCount, int minimumDeckSize, int maximumSameName, boolean mulliganRule,
boolean canCancelRingBearerSkirmish, boolean hasRuleOfFour, boolean winAtEndOfRegroup, boolean winOnControlling5Sites) {
boolean canCancelRingBearerSkirmish, boolean hasRuleOfFour, boolean winAtEndOfRegroup, boolean winOnControlling5Sites, boolean playtest) {
_adventure = adventure;
_library = library;
_name = name;
@@ -63,6 +64,7 @@ public class DefaultLotroFormat implements LotroFormat {
_hasRuleOfFour = hasRuleOfFour;
_winAtEndOfRegroup = winAtEndOfRegroup;
_winOnControlling5Sites = winOnControlling5Sites;
_isPlaytest = playtest;
}
@Override
@@ -105,6 +107,11 @@ public class DefaultLotroFormat implements LotroFormat {
return _winOnControlling5Sites;
}
@Override
public boolean isPlaytest() {
return _isPlaytest;
}
@Override
public List<Integer> getValidSets() {
return Collections.unmodifiableList(_validSets);

View File

@@ -46,12 +46,15 @@ public class LotroFormatLibrary {
Boolean winOnControlling5Sites = (Boolean) formatDef.get("winOnControlling5Sites");
if (winOnControlling5Sites == null)
winOnControlling5Sites = false;
Boolean isPlaytest = (Boolean) formatDef.get("playtest");
if (isPlaytest == null)
isPlaytest = false;
Number maximumSameNameCount = (Number) formatDef.get("maximumSameName");
int maximumSameName = (maximumSameNameCount != null) ? maximumSameNameCount.intValue() : 4;
final DefaultLotroFormat format = new DefaultLotroFormat(adventure, library, name, surveyUrl, block, true, 60, maximumSameName, true,
cancelRingBearerSkirmish, hasRuleOfFour, winAtEndOfRegroup, winOnControlling5Sites);
cancelRingBearerSkirmish, hasRuleOfFour, winAtEndOfRegroup, winOnControlling5Sites, isPlaytest);
JSONArray sets = (JSONArray) formatDef.get("set");
for (Object set : sets)