Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
mycard
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
syntax_j
mycard
Commits
2694f95c
Commit
2694f95c
authored
Sep 12, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ngModel problem
parent
611d58d0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
25 deletions
+72
-25
src/app/ygopro/ygopro.component.html
src/app/ygopro/ygopro.component.html
+6
-6
src/app/ygopro/ygopro.component.ts
src/app/ygopro/ygopro.component.ts
+66
-19
No files found.
src/app/ygopro/ygopro.component.html
View file @
2694f95c
...
...
@@ -26,13 +26,13 @@
</div>
<div
class=
"col-sm-8 input-group input-group-sm"
>
<label
i18n
class=
"input-group-text"
id=
"basic-addon1"
>
卡组
</label>
<select
class=
"form-select form-select-sm"
id=
"exampleSelect1"
name=
"deck"
[(ngModel)]=
"current
_d
eck"
>
<optgroup
*ngFor=
"let group of deck
Group()"
[label]=
"
group[0]"
>
<option
*ngFor=
"let deck of group[1]"
[value]=
"
group[0] + '/' + deck"
>
{{
deck}}
</option>
<select
class=
"form-select form-select-sm"
id=
"exampleSelect1"
name=
"deck"
[(ngModel)]=
"current
D
eck"
>
<optgroup
*ngFor=
"let group of deck
s_grouped"
[label]=
"group[0] === '.' ? '未分类卡组' :
group[0]"
>
<option
*ngFor=
"let deck of group[1]"
[value]=
"
deck"
>
{{deck.
deck}}
</option>
</optgroup>
</select>
<span
class=
"input-group-btn"
>
<button
id=
"edit_deck_button"
i18n
[disabled]=
"!appsService.allReady(app)"
class=
"btn btn-secondary btn-sm"
(click)=
"edit_deck(
current_deck
)"
>
编辑
</button>
<button
id=
"edit_deck_button"
i18n
[disabled]=
"!appsService.allReady(app)"
class=
"btn btn-secondary btn-sm"
(click)=
"edit_deck()"
>
编辑
</button>
</span>
</div>
</div>
...
...
@@ -121,10 +121,10 @@
<small
i18n
class=
"form-text text-muted"
>
最多 12 个字
</small>
</ng-container>
<ng-template
#private
>
<label
*ngIf=
"room.private"
for=
"game-create-
title
"
><i
class=
"fa fa-key"
aria-hidden=
"true"
></i>
<label
*ngIf=
"room.private"
for=
"game-create-
password
"
><i
class=
"fa fa-key"
aria-hidden=
"true"
></i>
<span
i18n
>
房间密码
</span></label>
<div
class=
"input-group input-group-sm"
>
<input
type=
"text"
maxlength=
"12"
class=
"form-control"
id=
"game-create-
title
"
name=
"title"
[(ngModel)]=
"host_password"
readonly
>
<input
type=
"text"
maxlength=
"12"
class=
"form-control"
id=
"game-create-
password
"
name=
"title"
[(ngModel)]=
"host_password"
readonly
>
<span
i18n-title
id=
"copy-wrapper"
class=
"input-group-btn"
data-bs-toggle=
"tooltip"
title=
"房间密码已复制到剪贴板"
>
<button
i18n-title
class=
"btn btn-secondary fa fa-clipboard"
type=
"button"
title=
"复制"
(click)=
"copy(host_password, $event)"
></button>
</span>
...
...
src/app/ygopro/ygopro.component.ts
View file @
2694f95c
...
...
@@ -99,6 +99,7 @@ interface YGOProDistroData {
replayPath
:
string
;
systemConf
?:
string
;
lastDeckFormat
?:
string
;
lastCategoryFormat
?:
string
;
}
interface
YGOProData
{
...
...
@@ -111,6 +112,11 @@ let matching: Subscription | undefined;
let
matching_arena
:
string
|
undefined
;
let
match_started_at
:
Date
;
export
interface
DeckAndCategory
{
category
:
string
;
deck
:
string
;
}
@
Component
({
moduleId
:
module
.
id
,
selector
:
'
ygopro
'
,
...
...
@@ -125,10 +131,11 @@ export class YGOProComponent implements OnInit, OnDestroy {
@
Output
()
points
:
EventEmitter
<
any
>
=
new
EventEmitter
();
decks
:
string
[]
=
[];
decks_grouped
:
[
string
,
string
[]][];
decks
:
DeckAndCategory
[]
=
[];
decks_grouped
:
[
string
,
DeckAndCategory
[]][];
replays
:
string
[]
=
[];
current_deck
:
string
;
currentDeck
:
DeckAndCategory
;
system_conf
?:
string
;
numfont
:
string
[];
textfont
:
string
[];
...
...
@@ -151,6 +158,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
this.currentServer = this.servers.find(s => s.id === this.selectingServerId);
}*/
lastDeckFormat
:
RegExp
;
lastCategoryFormat
:
RegExp
;
default_options
:
Options
=
{
mode
:
1
,
rule
:
this
.
settingsService
.
getLocale
().
startsWith
(
'
zh
'
)
?
0
:
1
,
...
...
@@ -304,6 +312,10 @@ export class YGOProComponent implements OnInit, OnDestroy {
this
.
lastDeckFormat
=
new
RegExp
(
ygoproData
.
ygopro
.
lastDeckFormat
);
}
if
(
ygoproData
.
ygopro
.
lastCategoryFormat
)
{
this
.
lastCategoryFormat
=
new
RegExp
(
ygoproData
.
ygopro
.
lastCategoryFormat
);
}
this
.
system_conf
=
this
.
app
.
systemConfPath
;
console
.
log
(
`Will load system conf file from
${
this
.
system_conf
}
`
);
await
this
.
refresh
(
true
);
...
...
@@ -433,6 +445,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
async
refresh
(
init
?:
boolean
)
{
this
.
decks
=
await
this
.
get_decks
();
this
.
decks_grouped
=
this
.
deckGroup
();
const
allDecks
=
_
.
flatten
(
this
.
decks_grouped
.
map
(
g
=>
g
[
1
]));
if
(
this
.
lastDeckFormat
)
{
const
systemConfString
=
await
this
.
load_system_conf
();
...
...
@@ -442,20 +455,37 @@ export class YGOProComponent implements OnInit, OnDestroy {
const
lastDeckMatch
=
systemConfString
.
match
(
this
.
lastDeckFormat
);
if
(
lastDeckMatch
)
{
lastDeck
=
lastDeckMatch
[
1
];
//
console.log(`Last deck ${lastDeck} read from ${this.system_conf}.`);
console
.
log
(
`Last deck
${
lastDeck
}
read from
${
this
.
system_conf
}
.`
);
}
else
{
//
console.error(`Deck pattern not found from pattern ${this.system_conf}: ${lastDeckMatch}`);
console
.
error
(
`Deck pattern not found from pattern
${
this
.
system_conf
}
:
${
lastDeckMatch
}
`
);
}
}
else
{
// console.error(`System conf ${this.system_conf} not found.`);
console
.
error
(
`System conf
${
this
.
system_conf
}
not found.`
);
}
let
lastCategory
=
'
.
'
;
if
(
systemConfString
&&
this
.
lastCategoryFormat
)
{
const
lastCategoryMatch
=
systemConfString
.
match
(
this
.
lastCategoryFormat
);
if
(
lastCategoryMatch
)
{
lastCategory
=
lastCategoryMatch
[
1
]
||
'
.
'
;
if
(
lastCategory
===
'
未分类卡组
'
||
lastCategory
===
'
人机卡组
'
)
{
lastCategory
=
'
.
'
;
}
console
.
log
(
`Last category
${
lastCategory
}
read from
${
this
.
system_conf
}
.`
);
}
else
{
console
.
error
(
`Category pattern not found from pattern
${
this
.
system_conf
}
:
${
lastCategoryMatch
}
`
);
}
}
if
(
lastDeck
&&
this
.
decks
.
includes
(
lastDeck
))
{
// console.log(`Got last deck ${lastDeck}.`);
this
.
current_deck
=
lastDeck
;
const
matchingDeck
=
allDecks
.
find
(
d
=>
d
.
deck
===
lastDeck
&&
d
.
category
===
lastCategory
);
if
(
matchingDeck
)
{
console
.
log
(
`Got last deck
${
matchingDeck
.
category
}
/
${
matchingDeck
.
deck
}
.`
);
this
.
currentDeck
=
matchingDeck
;
}
else
if
(
init
)
{
this
.
current_deck
=
this
.
decks
[
0
];
console
.
log
(
`Last deck
${
lastCategory
}
/
${
lastDeck
}
not found.`
);
this
.
currentDeck
=
allDecks
[
0
];
}
}
else
if
(
init
)
{
this
.
currentDeck
=
allDecks
[
0
];
}
this
.
replays
=
await
this
.
get_replays
();
...
...
@@ -474,17 +504,25 @@ export class YGOProComponent implements OnInit, OnDestroy {
}
};
async
get_decks
():
Promise
<
string
[]
>
{
async
get_decks
():
Promise
<
DeckAndCategory
[]
>
{
try
{
return
fg
.
sync
(
'
**/*.ydk
'
,
{
cwd
:
this
.
app
.
ygoproDeckPath
});
return
fg
.
sync
(
'
**/*.ydk
'
,
{
cwd
:
this
.
app
.
ygoproDeckPath
})
.
map
(
path
=>
this
.
getDeckObject
(
path
))
;
}
catch
(
error
)
{
console
.
error
(
`Load deck fail:
${
error
.
toString
()}
`
);
return
[];
}
}
deckGroup
():
[
string
,
string
[]][]
{
return
Object
.
entries
(
_
.
mapValues
(
_
.
groupBy
(
this
.
decks
,
p
=>
path
.
dirname
(
p
)),
g
=>
g
.
map
(
p
=>
path
.
basename
(
p
,
'
.ydk
'
))));
getDeckObject
(
deckPath
:
string
)
{
return
{
deck
:
path
.
basename
(
deckPath
,
'
.ydk
'
),
category
:
path
.
dirname
(
deckPath
)
}
}
deckGroup
():
[
string
,
DeckAndCategory
[]][]
{
const
categorizedDecks
=
this
.
decks
;
return
Object
.
entries
(
_
.
groupBy
(
categorizedDecks
,
d
=>
d
.
category
));
}
async
get_replays
():
Promise
<
string
[]
>
{
...
...
@@ -551,27 +589,36 @@ export class YGOProComponent implements OnInit, OnDestroy {
return fs.writeFile(this.system_conf, ini.unsafe(ini.stringify(data, <EncodeOptions>{whitespace: true})));
};*/
getDeckAndCategoryParam
()
{
const
deck
=
this
.
currentDeck
;
console
.
log
(
`Deck:
${
deck
.
category
}
/
${
deck
.
deck
}
`
)
return
{
category
:
deck
.
category
===
'
.
'
?
''
:
deck
.
category
,
deck
:
deck
.
deck
}
}
async
join
(
name
:
string
,
server
:
Server
)
{
/*let system_conf = await this.load_system_conf();
await this.fix_fonts(system_conf);
system_conf.lastdeck = this.current
_d
eck;
system_conf.lastdeck = this.current
D
eck;
system_conf.lastip = server.address;
system_conf.lasthost = server.address;
system_conf.lastport = server.port.toString();
system_conf.roompass = name;
system_conf.nickname = this.loginService.user.username;
await this.save_system_conf(system_conf);*/
// return this.start_game(['-h', server.address, '-p', server.port.toString(), '-w', name, '-n', this.loginService.user.username, '-d', this.current
_d
eck, '-j']);
return
this
.
start_game
(
'
main
'
,
{
server
,
password
:
name
,
username
:
this
.
loginService
.
user
.
username
,
deck
:
this
.
current_deck
});
// return this.start_game(['-h', server.address, '-p', server.port.toString(), '-w', name, '-n', this.loginService.user.username, '-d', this.current
D
eck, '-j']);
return
this
.
start_game
(
'
main
'
,
{
server
,
password
:
name
,
username
:
this
.
loginService
.
user
.
username
,
...
this
.
getDeckAndCategoryParam
()
});
};
async
edit_deck
(
deck
:
string
)
{
async
edit_deck
()
{
/*let system_conf = await this.load_system_conf();
await this.fix_fonts(system_conf);
system_conf.lastdeck = deck;
await this.save_system_conf(system_conf);*/
// return this.start_game(['-d', deck]);
return
this
.
start_game
(
'
deck
'
,
{
deck
}
);
return
this
.
start_game
(
'
deck
'
,
this
.
getDeckAndCategoryParam
()
);
}
async
watch_replay
(
replay
:
string
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment