Commit b086af2e authored by 刘家荣's avatar 刘家荣 💬
Browse files

reformat

parent f8e29933
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -21,8 +21,6 @@ import view.Frame.RoomFrame;
import view.Frame.RoomFrameReturnType.goOnline;

import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;
import java.net.UnknownHostException;
+131 −129
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ public class BulletAnim extends Thread {

	/**
	 * 创建新的弹幕,需要传入这个弹幕所显示的消息对象
	 *
	 * @param msg 消息
	 */
	private JLabel newBulletLabel(Msg msg) {
@@ -118,6 +119,7 @@ public class BulletAnim extends Thread {
	 * <br/>设某个消息的发出时间为T0,当前时间为T,屏幕宽度为w,
	 * <br/>那么弹幕在T0时刻的左端x坐标为w;
	 * <br/>左端x坐标关于T的函数:x - w = -v * (T - T0)
	 *
	 * @param msg 消息
	 * @return 左端x坐标
	 */
@@ -131,13 +133,13 @@ public class BulletAnim extends Thread {
	 * <br/>计算弹幕的像素长度
	 * <br/>
	 * <br/>不确定这种方式对不对,早晚有一天会要修改的
	 *
	 * @param msg 消息
	 * @return 长度
	 */
	// String.length -> byte
	// BULLET_FONT_SIZE -> px
	// 在 RGB 下 1 px = 3 byte

	private int evalLength(Msg msg) {
		return msg.content().length() * BULLET_FONT_SIZE * 3;   //不确定这种长度计算方式对不对
	}
+88 −85
Original line number Diff line number Diff line
@@ -4,14 +4,15 @@ package controller;
import model.AI;
import model.History;
import model.dataType.*;
import model.game.*;
import model.game.Chess;
import model.game.Game;
import model.game.Square;
import network.Client;
import network.OnlineInfo;
import network.dataType.OnlineStatus;
import view.Frame.ChessGameFrame;
import view.Com.ChessboardCom;
import view.Com.SquareCom;
import view.Frame.GameFrameReturnType.exitGame;
import view.Frame.ChessGameFrame;

import javax.swing.*;

@@ -35,6 +36,7 @@ public enum ChessClickController {

	/**
	 * 响应click事件,棋盘的交互逻辑
	 *
	 * @param squareCom 点中的方格
	 */
	public void onClick(SquareCom squareCom) {
@@ -42,7 +44,8 @@ public enum ChessClickController {
		Square square = squareCom.getBackSquare();
		Step step = null;
		//处理一番,结果写到step,否则step为null即无结果
        if(Game.instance.gameType == GameType.LOCAL_AI && Game.instance.getCurrentColor() != Game.instance.hostColor) return;
		if (Game.instance.gameType == GameType.LOCAL_AI && Game.instance.getCurrentColor() != Game.instance.hostColor)
			return;
		if (Game.instance.gameType == GameType.ONLINE) {
			if (OnlineInfo.status == OnlineStatus.SERVER_WAITING) {
				return;
+87 −85
Original line number Diff line number Diff line
package model;

import com.alibaba.fastjson2.JSON;
import network.Client;
import view.Theme;

import java.io.IOException;
@@ -50,6 +49,7 @@ public class Account {
	public Account(String name) throws IllegalArgumentException {
		this(name, Theme.DEFAULT);
	}

	public Account(String name, Theme theme) throws IllegalArgumentException {
		if (name == null || name.length() == 0) {
			throw new IllegalArgumentException("名称不能为空");
@@ -90,14 +90,16 @@ public class Account {
					res = tmp;
				}
			}
        } catch (IOException | IllegalArgumentException ignored){}
		} catch (IOException | IllegalArgumentException ignored) {
		}
		return res;
	}

	private void writeAccount() {
		try {
			Files.writeString(Path.of(SELF_ACCOUNT_PATH), JSON.toJSONString(this));
        }catch (Exception ignored){}
		} catch (Exception ignored) {
		}
	}

}
+87 −75
Original line number Diff line number Diff line
@@ -41,9 +41,21 @@ public class History{
		int type = 0;
		int i = -1;
		switch (step) {
            case FlipStep flipStep -> {type = 0; i = flipSteps.size(); flipSteps.add(flipStep);}
            case MoveStep moveStep -> {type = 1; i = moveSteps.size(); moveSteps.add(moveStep);}
            case EatStep eatStep -> {type = 2; i = eatSteps.size(); eatSteps.add(eatStep);}
			case FlipStep flipStep -> {
				type = 0;
				i = flipSteps.size();
				flipSteps.add(flipStep);
			}
			case MoveStep moveStep -> {
				type = 1;
				i = moveSteps.size();
				moveSteps.add(moveStep);
			}
			case EatStep eatStep -> {
				type = 2;
				i = eatSteps.size();
				eatSteps.add(eatStep);
			}
			default -> {
				return;
			}
Loading