Ci: check space and LF (#55)

This commit is contained in:
notify 2023-02-26 16:51:29 +08:00 committed by GitHub
parent 9ac89caa1f
commit a579cf2a59
36 changed files with 93 additions and 75 deletions

18
.github/workflows/check-white-space.yml vendored Normal file
View File

@ -0,0 +1,18 @@
name: Check Whitespace and New Line
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Check trailing space
run: if grep -rIn "[[:blank:]]$"; then exit 2; else echo OK; fi
- name: Check no new line at EOF
run: for f in $(grep -rIl ""); do if test $(tail -c 1 $f); then echo $f; fail=1; fi; done; if test $fail; then exit 1; fi

View File

@ -5,7 +5,7 @@
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<supports-screens

View File

@ -307,10 +307,10 @@ local function mergeMoves(moves)
local ret = {}
local temp = {}
for _, move in ipairs(moves) do
local info = string.format("%q,%q,%q,%q,%s,%s",
local info = string.format("%q,%q,%q,%q,%s,%s",
move.from, move.to, move.fromArea, move.toArea,
move.specialName, move.fromSpecialName)
if temp[info] == nil then
if temp[info] == nil then
temp[info] = {
ids = {},
from = move.from,

View File

@ -508,7 +508,7 @@ Fk:loadTranslationTable{
["#LoseSkill"] = "%from 失去了技能“%arg”",
-- moveCards (they are sent by notifyMoveCards)
["$DrawCards"] = "%from 摸了 %arg 张牌 %card",
["$DiscardCards"] = "%from 弃置了 %arg 张牌 %card",

View File

@ -38,7 +38,7 @@ end
---@param pack Package
function Engine:loadPackage(pack)
assert(pack:isInstanceOf(Package))
if self.packages[pack.name] ~= nil then
if self.packages[pack.name] ~= nil then
error(string.format("Duplicate package %s detected", pack.name))
end
self.packages[pack.name] = pack

View File

@ -76,11 +76,11 @@ local function matchCard(matcher, card)
return false
end
-- TODO: generalName
if matcher.cardType and not table.contains(matcher.cardType, typetable[card.type]) then
return false
end
if matcher.id and not table.contains(matcher.id, card.id) then
return false
end

View File

@ -109,7 +109,7 @@ end
---@param flag string
function Player:setFlag(flag)
if flag == "." then
if flag == "." then
self:clearFlags()
return
end
@ -302,7 +302,7 @@ function Player:getMaxCards()
end
if max_fixed then baseValue = math.max(max_fixed, 0) end
for _, skill in ipairs(status_skills) do
local c = skill:getCorrect(self)
baseValue = baseValue + c
@ -349,7 +349,7 @@ function Player:distanceTo(other)
if correct == nil then correct = 0 end
ret = ret + correct
end
if self.fixedDistance[other] then
ret = self.fixedDistance[other]
end

View File

@ -23,7 +23,7 @@ local function readCommonSpecToSkill(skill, spec)
skill.anim_type = spec.anim_type
if spec.attached_equip then
assert(type(spec.attached_equip) == "string")
assert(type(spec.attached_equip) == "string")
skill.attached_equip = spec.attached_equip
end
end
@ -355,7 +355,7 @@ function fk.CreateTrickCard(spec)
if spec.suit then assert(type(spec.suit) == "number") end
if spec.number then assert(type(spec.number) == "number") end
local card = TrickCard:new(spec.name, spec.suit, spec.number)
local card = TrickCard:new(spec.name, spec.suit, spec.number)
card.skill = spec.skill or defaultCardSkill
return card
end

View File

@ -138,7 +138,7 @@ fkp.functions.buildPrompt = function(base, src, dest, arg, arg2)
end
fkp.functions.askForChoice = function(player, choices, reason)
return player.room:askForChoice(player, choices, reason)
return player.room:askForChoice(player, choices, reason)
end
fkp.functions.askForPlayerChosen = function(player, targets, reason, prompt, optional, notify)

View File

@ -7,7 +7,7 @@ local RandomAI = AI:subclass("RandomAI")
local function useActiveSkill(self, skill, card)
local room = self.room
local player = self.player
local filter_func = skill.cardFilter
if card then
filter_func = function() return false end
@ -111,7 +111,7 @@ local function useVSSkill(self, skill, pattern, cancelable, extra_data)
end
max_try_time = max_try_time - 1
end
return nil
return nil
end
local random_cb = {}

View File

@ -55,7 +55,7 @@ function Room:initialize(_room)
self.room = _room
self.room.startGame = function(_self)
Room.initialize(self, _room) -- clear old data
Room.initialize(self, _room) -- clear old data
local main_co = coroutine.create(function()
self:run()
end)
@ -550,7 +550,7 @@ function Room:notifyMoveCards(players, card_moves, forceVisible)
or infosContainArea(move.moveInfo, Card.Processing)
or move.toArea == Card.Processing
-- TODO: PlayerSpecial
if not move.moveVisible then
for _, info in ipairs(move.moveInfo) do
info.cardId = -1
@ -1436,7 +1436,7 @@ function Room:doCardUseEffect(cardUseEvent)
if #realCardIds == 0 then
return
end
local target = TargetGroup:getRealTargets(cardUseEvent.tos)[1]
if not self:getPlayerById(target).dead then
local findSameCard = false
@ -1543,7 +1543,7 @@ function Room:doCardEffect(cardEffectEvent)
end
break
end
if not cardEffectEvent.toCard and (not (self:getPlayerById(cardEffectEvent.to):isAlive() and cardEffectEvent.to) or #self:deadPlayerFilter(TargetGroup:getRealTargets(cardEffectEvent.tos)) == 0) then
break
end
@ -1691,7 +1691,7 @@ function Room:moveCards(...)
fromSpecialName = cardsMoveInfo.from and self:getPlayerById(cardsMoveInfo.from):getPileNameOfId(id),
})
end
---@type CardsMoveStruct
local cardsMoveStruct = {
moveInfo = infos,
@ -1705,7 +1705,7 @@ function Room:moveCards(...)
specialName = cardsMoveInfo.specialName,
specialVisible = cardsMoveInfo.specialVisible,
}
table.insert(cardsMoveStructs, cardsMoveStruct)
end
end
@ -1766,7 +1766,7 @@ function Room:moveCards(...)
Fk:filterCard(info.cardId, self:getPlayerById(data.to))
local currentCard = Fk:getCardById(info.cardId)
if
if
data.toArea == Player.Equip and
currentCard.type == Card.TypeEquip and
data.to ~= nil and
@ -1855,7 +1855,7 @@ function Room:moveCardTo(card, to_place, target, reason, skill_name, special_nam
moveReason = reason,
skillName = skill_name,
specialName = special_name,
moveVisible = visible,
moveVisible = visible,
}
end
@ -2099,7 +2099,7 @@ function Room:enterDying(dyingStruct)
self.logic:trigger(fk.AskForPeaches, dyingPlayer, dyingStruct)
self.logic:trigger(fk.AskForPeachesDone, dyingPlayer, dyingStruct)
end
if not dyingPlayer.dead then
dyingPlayer.dying = false
self:broadcastProperty(dyingPlayer, "dying")
@ -2112,7 +2112,7 @@ function Room:killPlayer(deathStruct)
local victim = self:getPlayerById(deathStruct.who)
victim.dead = true
table.removeOne(self.alive_players, victim)
local logic = self.logic
logic:trigger(fk.BeforeGameOverJudge, victim, deathStruct)
@ -2132,7 +2132,7 @@ function Room:killPlayer(deathStruct)
}
end
self:sendLogEvent("Death", {to = victim.id})
self:broadcastProperty(victim, "role")
self:broadcastProperty(victim, "dead")

View File

@ -310,7 +310,7 @@ function ServerPlayer:changePhase(from_phase, to_phase)
self.phase = to_phase
room:notifyProperty(self, self, "phase")
if #self.phases > 0 then
if #self.phases > 0 then
table.remove(self.phases, 1)
end

2
packages/.gitignore vendored
View File

@ -4,4 +4,4 @@
!test/
!manuvering/
!.gitignore
!init.sql
!init.sql

View File

@ -77,7 +77,7 @@ GameRule = fk.CreateTriggerSkill{
move_to_notify.moveInfo = {}
move_to_notify.moveReason = fk.ReasonDraw
for _, id in ipairs(cardIds) do
table.insert(move_to_notify.moveInfo,
table.insert(move_to_notify.moveInfo,
{ cardId = id, fromArea = Card.DrawPile })
end
room:notifyMoveCards(nil, {move_to_notify})
@ -104,7 +104,7 @@ GameRule = fk.CreateTriggerSkill{
end
room:sendLog{ type = "$AppendSeparator" }
player:addMark("Global_TurnCount")
if not player.faceup then
player:setFlag("-Global_FirstRound")
@ -119,10 +119,10 @@ GameRule = fk.CreateTriggerSkill{
error("You should never proceed PhaseNone")
end,
[Player.RoundStart] = function()
end,
[Player.Start] = function()
end,
[Player.Judge] = function()
local cards = player:getCardIds(Player.Judge)
@ -173,10 +173,10 @@ GameRule = fk.CreateTriggerSkill{
end
end,
[Player.Finish] = function()
end,
[Player.NotActive] = function()
end,
})
end,

View File

@ -669,7 +669,7 @@ local keji = fk.CreateTriggerSkill{
can_refresh = function(self, event, target, player, data)
if not (target == player and player:hasSkill(self.name)) then
return false
end
end
if event == fk.CardResponding then
return data.card.name == "slash"
elseif event == fk.EventPhaseStart then

View File

@ -35,7 +35,7 @@ local slashSkill = fk.CreateActiveSkill{
on_effect = function(self, room, effect)
local to = effect.to
local from = effect.from
room:damage({
from = room:getPlayerById(from),
to = room:getPlayerById(to),
@ -146,7 +146,7 @@ local peachSkill = fk.CreateActiveSkill{
on_effect = function(self, room, effect)
local to = effect.to
local from = effect.from
room:recover({
who = room:getPlayerById(to),
num = 1,

View File

@ -17,7 +17,7 @@ GraphicsBox {
spacing: 10
Text {
text: root.custom_string
text: root.custom_string
color: "#E4D5A0"
}

View File

@ -9,7 +9,7 @@ function createClientPages() {
mainWindow.generalsOverviewPage = generalsOverviewPage;
mainWindow.cardsOverviewPage = cardsOverviewPage;
}
}
}
var callbacks = {};

View File

@ -8,7 +8,7 @@ Item {
property bool loaded: false
ListView {
ListView {
width: Math.floor(root.width / 98) * 98
height: parent.height
anchors.centerIn: parent
@ -23,7 +23,7 @@ Item {
columns: root.width / 98
Repeater {
model: JSON.parse(Backend.callLuaFunction("GetCards", [name]))
CardItem {
CardItem {
autoBack: false
Component.onCompleted: {
let data = JSON.parse(Backend.callLuaFunction("GetCardData", [modelData]));

View File

@ -23,7 +23,7 @@ Item {
columns: root.width / 98
Repeater {
model: JSON.parse(Backend.callLuaFunction("GetGenerals", [name]))
GeneralCardItem {
GeneralCardItem {
autoBack: false
name: modelData
onClicked: {

View File

@ -12,7 +12,7 @@ Item {
color: "#88888888"
radius: 2
}
Column {
spacing: 8
ComboBox {

View File

@ -79,7 +79,7 @@ Item {
ListView {
id: packageList
anchors.fill: parent
contentHeight: packageDelegate.height * count
ScrollBar.vertical: ScrollBar {}
header: RowLayout {

View File

@ -40,7 +40,7 @@ Item {
MediaPlayer {
id: bgm
source: config.bgmFile
// loops: MediaPlayer.Infinite
onPlaybackStateChanged: {
if (playbackState == MediaPlayer.StoppedState && roomScene.isStarted)
@ -104,7 +104,7 @@ Item {
if (popupBox.item != null) {
popupBox.item.finished();
}
}
}
}
},
@ -412,7 +412,7 @@ Item {
dragMargin: 0
scale: mainWindow.scale
transformOrigin: Item.TopLeft
ColumnLayout {
anchors.fill: parent

View File

@ -351,7 +351,7 @@ Item {
duration: 100
}
}
function tremble() {
trembleAnimation.start()
}

View File

@ -72,7 +72,7 @@ function doOkButton() {
}
));
return;
}
}
replyToServer("1");
}
@ -91,7 +91,7 @@ function doCancelButton() {
replyToServer("__cancel");
return;
}
replyToServer("__cancel");
}
@ -486,7 +486,7 @@ callbacks["ArrangeSeats"] = function(jsonData) {
dashboardModel.seatNumber = order.indexOf(Self.id) + 1;
dashboardModel.general = "";
roomScene.dashboardModelChanged();
// make Self to the first of list, then reorder photomodel
let selfIndex = order.indexOf(Self.id);
let after = order.splice(selfIndex);
@ -497,7 +497,7 @@ callbacks["ArrangeSeats"] = function(jsonData) {
let item = photoModel.get(i);
item.index = photoOrder.indexOf(item.id);
}
arrangePhotos();
}
@ -516,14 +516,14 @@ callbacks["MoveFocus"] = function(jsonData) {
let data = JSON.parse(jsonData);
let focuses = data[0];
let command = data[1];
let item, model;
for (let i = 0; i < playerNum - 1; i++) {
model = photoModel.get(i);
if (focuses.indexOf(model.id) != -1) {
item = photos.itemAt(i);
item.progressBar.visible = true;
item.progressTip = Backend.translate(command)
item.progressTip = Backend.translate(command)
+ Backend.translate(" thinking...");
if (command === "PlayCard") {

View File

@ -15,7 +15,7 @@ Item {
color: "#88888888"
radius: 2
}
Column {
spacing: 8
TextField {

View File

@ -26,7 +26,7 @@ ListView {
easing.type: Easing.InOutQuad
}
}
delegate: Toast {
Component.onCompleted: {
show(text, duration);

View File

@ -90,16 +90,16 @@ Item {
property bool stateVisible: false
states: [
State {
State {
when: globalPopupDim.stateVisible
PropertyChanges { target: globalPopupDim; opacity: 0.5 }
},
State {
State {
when: !globalPopupDim.stateVisible
PropertyChanges { target: globalPopupDim; opacity: 0.0 }
}
]
transitions: Transition {
NumberAnimation { properties: "opacity"; easing.type: Easing.InOutQuad }
}
@ -109,7 +109,7 @@ Item {
id: globalPopup
property string source: ""
modal: true
dim: false // cannot animate the dim
dim: false // cannot animate the dim
focus: true
opacity: mainWindow.busy ? 0 : 1
closePolicy: Popup.CloseOnEscape

View File

@ -7,14 +7,14 @@ class ClientPlayer : public Player {
Q_OBJECT
Q_PROPERTY(int id READ getId CONSTANT)
Q_PROPERTY(QString screenName
READ getScreenName
WRITE setScreenName
Q_PROPERTY(QString screenName
READ getScreenName
WRITE setScreenName
NOTIFY screenNameChanged
)
Q_PROPERTY(QString avatar
READ getAvatar
WRITE setAvatar
READ getAvatar
WRITE setAvatar
NOTIFY avatarChanged
)

View File

@ -182,14 +182,14 @@ int main(int argc, char *argv[])
QTranslator translator;
Q_UNUSED(translator.load("zh_CN.qm"));
QCoreApplication::installTranslator(&translator);
QmlBackend backend;
backend.setEngine(engine);
#ifndef Q_OS_WASM
Pacman = new PackMan;
#endif
engine->rootContext()->setContextProperty("Backend", &backend);
engine->rootContext()->setContextProperty("Pacman", Pacman);

View File

@ -61,7 +61,7 @@ public:
LuaFunction startGame;
QString fetchRequest();
void pushRequest(const QString &req);
void pushRequest(const QString &req);
bool hasRequest() const;
signals:

View File

@ -35,7 +35,7 @@ public:
signals:
void disconnected();
private:
ClientSocket *socket; // socket for communicating with client
Router *router;

View File

@ -5,7 +5,7 @@ class Shell: public QThread {
Q_OBJECT
public:
Shell();
enum Color {
Black,
Red,

View File

@ -47,7 +47,7 @@ static int GetMicroSecond(lua_State *L) {
long microsecond = tv.tv_sec * 1000000 + tv.tv_usec;
lua_pushnumber(L, microsecond);
return 1;
}
}
%}
void qDebug(const char *msg, ...);

View File

@ -48,7 +48,7 @@ public:
const QString &command,
const QString &jsonData
);
void gameOver();
LuaFunction startGame;
@ -91,7 +91,7 @@ void Room::roomStart() {
}
lua_pop(L, 1);
}
%}
%nodefaultctor ServerPlayer;

View File

@ -234,7 +234,7 @@ void QmlBackend::playSound(const QString &name, int index) {
i++;
}
index = i == 0 ? 0 : (QRandomGenerator::global()->generate()) % i + 1;
index = i == 0 ? 0 : (QRandomGenerator::global()->generate()) % i + 1;
}
if (index != 0)
fname = fname + QString::number(index) + ".mp3";
@ -242,7 +242,7 @@ void QmlBackend::playSound(const QString &name, int index) {
fname = fname + ".mp3";
if (!QFile::exists(fname)) return;
auto player = new QMediaPlayer;
auto output = new QAudioOutput;
player->setAudioOutput(output);