Skip to content

Commit

Permalink
more logger migration
Browse files Browse the repository at this point in the history
  • Loading branch information
alyssaruth committed Dec 7, 2023
1 parent 0a4bc3d commit 6dba9f4
Show file tree
Hide file tree
Showing 16 changed files with 258 additions and 520 deletions.
8 changes: 3 additions & 5 deletions client/src/main/java/object/RoomTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@

import org.w3c.dom.Document;

import util.Debug;
import util.EntropyColour;
import util.MessageUtil;
import util.TableUtil;

import static utils.InjectedThings.logger;

public final class RoomTable extends JTable
implements MouseListener
{
Expand Down Expand Up @@ -158,10 +159,7 @@ private void updateRooms(List<RoomWrapper> rooms)
RoomWrapper tableRoom = lobby.getRoomForName(roomName);
if (tableRoom == null)
{
Debug.append("roomName: " + roomName);
Debug.append("rowCount: " + rowCount);
Debug.append("rooms from server: " + rooms);
Debug.stackTraceNoError("NULL room in lobby hashmap, despite it being in tablemodel");
logger.warn("missingRoom", roomName + " missing from lobby hashmap, despite being in our local table. Rooms from server: " + rooms);
}

RoomWrapper listRoom = getListRoomForName(rooms, roomName);
Expand Down
79 changes: 16 additions & 63 deletions client/src/main/java/online/screen/GameRoom.java
Original file line number Diff line number Diff line change
@@ -1,71 +1,26 @@
package online.screen;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Image;

import object.*;
import online.util.XmlBuilderClient;
import org.w3c.dom.Document;
import screen.*;
import util.*;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Random;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.prefs.Preferences;

import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextPane;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;

import object.Bid;
import object.BidListCellRenderer;
import object.ChallengeBid;
import object.IllegalBid;
import object.LeftBid;
import object.Player;
import object.PulsingTextLabel;
import object.RoomWrapper;
import online.util.XmlBuilderClient;

import org.w3c.dom.Document;

import screen.BackgroundPanel;
import screen.BidPanel;
import screen.HandPanelMk2;
import screen.ReplayDialog;
import screen.ScreenCache;
import screen.TransparentPanel;
import util.AchievementsUtil;
import util.BidListener;
import util.Debug;
import util.DialogUtil;
import util.EntropyUtil;
import util.GameConstants;
import util.GameUtil;
import util.MessageUtil;
import util.Registry;
import util.ReplayFileUtil;
import util.RevealListener;
import static utils.InjectedThings.logger;

/**
* This is an actual room as seen by the player
Expand Down Expand Up @@ -788,8 +743,6 @@ public void startGame(int personToStart)
}
else
{
Debug.append("Disabling bidPanel on start. personToStart = " + personToStart
+ ", personToStartLocal = " + personToStartLocal);
enableBidPanel(false);
}
}
Expand Down Expand Up @@ -1225,7 +1178,7 @@ public void deleteReplayNode()
}
catch (Throwable t)
{
Debug.append("Caught " + t + " when deleting online replay node.");
logger.error("preferenceError", "Error deleting replay node", t);
}
}

Expand Down
42 changes: 11 additions & 31 deletions client/src/main/java/online/util/ResponseHandler.java
Original file line number Diff line number Diff line change
@@ -1,44 +1,24 @@

package online.util;

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

import javax.crypto.SecretKey;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;

import object.Bid;
import object.OnlineMessage;
import object.OnlineUsername;
import object.RoomWrapper;
import online.screen.AccountSettingsDialog;
import online.screen.ChangePasswordDialog;
import online.screen.ConnectingDialog;
import online.screen.EntropyLobby;
import online.screen.GameRoom;
import online.screen.Leaderboard;
import online.screen.LoginDialog;
import online.screen.NewAccountDialog;
import online.screen.OnlineChatPanel;
import online.screen.OnlineStatsPanel;

import online.screen.*;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

import screen.ScreenCache;
import util.AchievementsUtil;
import util.Debug;
import util.DialogUtil;
import util.EncryptionUtil;
import util.MessageUtil;
import util.OnlineConstants;
import util.Registry;
import util.UpdateChecker;
import util.XmlConstants;
import util.XmlUtil;
import util.*;

import javax.crypto.SecretKey;
import javax.swing.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import static utils.InjectedThings.logger;

public class ResponseHandler implements XmlConstants
{
Expand Down Expand Up @@ -155,7 +135,7 @@ else if (responseName.equals(RESPONSE_TAG_STACK_TRACE))
}
else if (responseName.equals(RESPONSE_TAG_SOCKET_TIME_OUT))
{
Debug.append("Resending " + messageStr + " because Server had a SocketTimeout");
logger.info("resendingMessage", "Resending " + messageStr + " because Server had a SocketTimeout");
MessageUtil.sendMessage(messageStr, 0);
}
else
Expand Down
37 changes: 10 additions & 27 deletions client/src/main/java/screen/GameScreen.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
package screen;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;

import javax.swing.DefaultListModel;

import object.Bid;
import object.ChallengeBid;
import object.IllegalBid;
import object.Player;
import util.AchievementsUtil;
import util.BidListener;
import util.CardsUtil;
import util.CpuStrategies;
import util.Debug;
import util.DialogUtil;
import util.GameUtil;
import util.Registry;
import util.RegistryUtil;
import util.ReplayFileUtil;
import util.RevealListener;
import util.StrategyParms;
import util.*;

import javax.swing.*;
import java.util.Timer;
import java.util.*;

import static utils.InjectedThings.logger;

public abstract class GameScreen extends TransparentPanel
implements BidListener,
Expand Down Expand Up @@ -815,19 +802,17 @@ protected void randomlyReplaceCardsWithJokers()
{
Random random = new Random();
int jokersToAdd = random.nextInt(5) + 1; //1-5
Debug.append("Adding " + jokersToAdd + " jokers");
logger.info("rainingJokers", "Adding " + jokersToAdd + " jokers");

String[] allCards = getConcatenatedHands();
Debug.append("allCards: " + CardsUtil.getHandStr(allCards));

while (CardsUtil.containsNonJoker(allCards) && jokersToAdd > 0)
{
replaceRandomCardWithJoker();
allCards = getConcatenatedHands();
jokersToAdd--;
}

Debug.append("Done replacing. allCards = " + CardsUtil.getHandStr(allCards));

displayHands();
}
}
Expand All @@ -846,8 +831,7 @@ private void replaceRandomCardWithJoker()
replaceRandomCardWithJoker();
return;
}

Debug.append("Replacing " + hand[position] + " with " + jokerToAdd);

hand[position] = jokerToAdd;
}

Expand All @@ -863,7 +847,6 @@ private String[] pickHandWithNonJokerAtRandom()
}
else
{
Debug.append("Picked " + CardsUtil.getHandStr(hand));
return hand;
}
}
Expand Down
36 changes: 9 additions & 27 deletions client/src/main/java/screen/HandPanelMk2.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package screen;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import object.CardLabel;
import object.PlayerLabel;
import online.util.XmlBuilderClient;
import org.w3c.dom.Document;
import util.*;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
Expand All @@ -13,28 +18,6 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.prefs.Preferences;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.border.EmptyBorder;

import object.CardLabel;
import object.PlayerLabel;
import online.util.XmlBuilderClient;

import org.w3c.dom.Document;

import util.AchievementsUtil;
import util.CardsUtil;
import util.Debug;
import util.MessageUtil;
import util.Registry;
import util.RevealListener;

public class HandPanelMk2 extends TransparentPanel
implements ActionListener,
MouseListener,
Expand Down Expand Up @@ -981,7 +964,6 @@ private void playerCardClicked(CardLabel source)
{
if (isRevealed(source))
{
Debug.append("Player clicked a card that was already revealed.");
return;
}

Expand Down
Loading

0 comments on commit 6dba9f4

Please sign in to comment.