code-battles 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -14518,7 +14518,7 @@ const Round = () => {
14518
14518
  }
14519
14519
  React.useEffect(() => {
14520
14520
  if (remaining > 0) {
14521
- runNoUI(currentMap, apis, currentPlayers, false);
14521
+ runNoUI(currentMap, apis, currentPlayers, "", false);
14522
14522
  }
14523
14523
  }, [remaining]);
14524
14524
  React.useEffect(updatePointModifier, [results]);
@@ -14577,7 +14577,7 @@ const Round = () => {
14577
14577
  React.createElement(core.Button, { leftSection: React.createElement("i", { className: "fa-solid fa-play" }), size: "xs", onClick: () => navigate(`/simulation/${round.map.replaceAll(" ", "-")}/${round.players.join("-")}?showcase=true`) }, "Simulate"),
14578
14578
  React.createElement(core.Button, { leftSection: React.createElement("i", { className: "fa-solid fa-forward" }), size: "xs", onClick: () => {
14579
14579
  if (roundIterations === 1) {
14580
- runNoUI(round.map, apis, round.players, true);
14580
+ runNoUI(round.map, apis, round.players, "", true);
14581
14581
  }
14582
14582
  else {
14583
14583
  currentMap = round.map;
@@ -15850,7 +15850,10 @@ const confetti = {
15850
15850
  };
15851
15851
 
15852
15852
  const AutoScrollButton = () => {
15853
- const [autoScroll, setAutoScroll] = React.useState(true);
15853
+ const [autoScroll, setAutoScroll] = useLocalStorage({
15854
+ key: "Auto Scroll",
15855
+ defaultValue: true,
15856
+ });
15854
15857
  React.useEffect(() => {
15855
15858
  // @ts-ignore
15856
15859
  window.autoScroll = autoScroll;
@@ -15868,8 +15871,14 @@ const ShowLogsButtons = ({ playerNames, showLogs, setShowLogs, }) => {
15868
15871
  };
15869
15872
 
15870
15873
  const LogViewer = ({ playerNames }) => {
15871
- const [showLogs, setShowLogs] = React.useState([]);
15872
- const [logs, setLogs] = React.useState([]);
15874
+ const [showLogs, setShowLogs] = useLocalStorage({
15875
+ key: "Show Logs",
15876
+ defaultValue: [],
15877
+ });
15878
+ const [logs, setLogs] = useLocalStorage({
15879
+ key: "Logs",
15880
+ defaultValue: [],
15881
+ });
15873
15882
  React.useEffect(() => {
15874
15883
  // @ts-ignore
15875
15884
  setShowLogs(playerNames.map(() => true));
@@ -404,6 +404,9 @@ class CodeBattles(
404
404
 
405
405
  For game-global log entries (not coming from a specific player), don't specify a ``player_index``.
406
406
  """
407
+ if not isinstance(text, str):
408
+ text = str(text)
409
+
407
410
  if is_web():
408
411
  console_log(-1 if player_index is None else player_index, text, color)
409
412
  else:
package/dist/esm/index.js CHANGED
@@ -14516,7 +14516,7 @@ const Round = () => {
14516
14516
  }
14517
14517
  useEffect(() => {
14518
14518
  if (remaining > 0) {
14519
- runNoUI(currentMap, apis, currentPlayers, false);
14519
+ runNoUI(currentMap, apis, currentPlayers, "", false);
14520
14520
  }
14521
14521
  }, [remaining]);
14522
14522
  useEffect(updatePointModifier, [results]);
@@ -14575,7 +14575,7 @@ const Round = () => {
14575
14575
  React.createElement(Button, { leftSection: React.createElement("i", { className: "fa-solid fa-play" }), size: "xs", onClick: () => navigate(`/simulation/${round.map.replaceAll(" ", "-")}/${round.players.join("-")}?showcase=true`) }, "Simulate"),
14576
14576
  React.createElement(Button, { leftSection: React.createElement("i", { className: "fa-solid fa-forward" }), size: "xs", onClick: () => {
14577
14577
  if (roundIterations === 1) {
14578
- runNoUI(round.map, apis, round.players, true);
14578
+ runNoUI(round.map, apis, round.players, "", true);
14579
14579
  }
14580
14580
  else {
14581
14581
  currentMap = round.map;
@@ -15848,7 +15848,10 @@ const confetti = {
15848
15848
  };
15849
15849
 
15850
15850
  const AutoScrollButton = () => {
15851
- const [autoScroll, setAutoScroll] = useState(true);
15851
+ const [autoScroll, setAutoScroll] = useLocalStorage({
15852
+ key: "Auto Scroll",
15853
+ defaultValue: true,
15854
+ });
15852
15855
  useEffect(() => {
15853
15856
  // @ts-ignore
15854
15857
  window.autoScroll = autoScroll;
@@ -15866,8 +15869,14 @@ const ShowLogsButtons = ({ playerNames, showLogs, setShowLogs, }) => {
15866
15869
  };
15867
15870
 
15868
15871
  const LogViewer = ({ playerNames }) => {
15869
- const [showLogs, setShowLogs] = useState([]);
15870
- const [logs, setLogs] = useState([]);
15872
+ const [showLogs, setShowLogs] = useLocalStorage({
15873
+ key: "Show Logs",
15874
+ defaultValue: [],
15875
+ });
15876
+ const [logs, setLogs] = useLocalStorage({
15877
+ key: "Logs",
15878
+ defaultValue: [],
15879
+ });
15871
15880
  useEffect(() => {
15872
15881
  // @ts-ignore
15873
15882
  setShowLogs(playerNames.map(() => true));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-battles",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "A library for building interactive competitive coding battles",
5
5
  "repository": "https://github.com/noamzaks/code-battles",
6
6
  "homepage": "https://code-battles.readthedocs.org",