Fancy prints and i18n basics
Signed-off-by: szdytom <szdytom@qq.com>
This commit is contained in:
parent
0528c13fff
commit
66b93b81cd
@ -1,6 +1,6 @@
|
||||
# icollect-alpha
|
||||
|
||||
ICollect-Alpha 是一个使用 Carpet 脚本的“物品收集x狼人杀 Minecraft小游戏”实现。
|
||||
ICollect-Alpha 是一个使用 [Carpet 脚本](https://github.com/gnembon/fabric-carpet) 的“物品收集x狼人杀 Minecraft小游戏”实现。
|
||||
|
||||
## 规则
|
||||
|
||||
|
@ -9,7 +9,9 @@ __config() -> {
|
||||
},
|
||||
};
|
||||
|
||||
import('ica-libs', 'shuffleList', 'countCareer', 'playerListNbt', 'findVoteMax', 'resetVotes');
|
||||
import('ica-libs', 'shuffleList', 'countCareer', 'playerListNbt'
|
||||
, 'findVoteMax', 'resetVotes');
|
||||
import('ica-i18n', 'getLocaleKey');
|
||||
|
||||
__on_start() -> (
|
||||
if(nbt_storage('ica:data'):'Goals' == null, (
|
||||
@ -32,7 +34,8 @@ clearBossbars() -> (
|
||||
|
||||
cleanPlayerTags() -> (
|
||||
for(player('all'), modify(_, 'clear_tag', ['ica.piggy'
|
||||
, 'ica.wolf', 'ica.hunter', 'ica.fireball_spyglasser', 'ica.spyglass_fireball'
|
||||
, 'ica.wolf', 'ica.hunter', 'ica.firework_hunter'
|
||||
, 'ica.fireball_spyglasser', 'ica.spyglass_fireball'
|
||||
, 'ica.voter', 'ica.flyer', 'ica.spyglasser_cooldown'
|
||||
, 'ica.coordinator', 'ica.deceased', 'ica.participant'
|
||||
, 'ica.firework_spyglasser', 'ica.build_spyglasser'
|
||||
@ -103,17 +106,18 @@ endGameTitle(p, m, s) -> (
|
||||
);
|
||||
|
||||
endTimeout(iv) -> (
|
||||
endGameTitle(getPigPlayers(), 'Timeout!'
|
||||
, str('You didn\'t complete %d goals in time.', iv));
|
||||
endGameTitle(getWolfPlayers(), 'You won!'
|
||||
, str('Those fools have failed, good job.', iv));
|
||||
endGameTitle(getPigPlayers(), getLocaleKey('pig.timeout.title')
|
||||
, str(getLocaleKey('pig.timeout.subtitle'), iv));
|
||||
endGameTitle(getWolfPlayers(), getLocaleKey('wolf.timeout.subtitle')
|
||||
, str(getLocaleKey('wolf.timeout.subtitle'), iv));
|
||||
endCleanup();
|
||||
);
|
||||
|
||||
endFinish() -> (
|
||||
endGameTitle(getPigPlayers(), 'Congratulations!', 'You have completed all the goals.');
|
||||
endGameTitle(getWolfPlayers(), 'Oh no!'
|
||||
, str('They have completed all the goals.', iv));
|
||||
endGameTitle(getPigPlayers(), getLocaleKey('pig.complete.title')
|
||||
, getLocaleKey('pig.complete.subtitle'));
|
||||
endGameTitle(getWolfPlayers(), getLocaleKey('wolf.complete.title')
|
||||
, getLocaleKey('wolf.complete.subtitle'));
|
||||
endCleanup();
|
||||
);
|
||||
|
||||
@ -133,17 +137,17 @@ actionbarMessage(msg) -> (
|
||||
|
||||
warnDeadline(dt) -> (
|
||||
if (dt == 1200, (
|
||||
actionbarMessage('[WARN] Submission deadline in 1 minute.');
|
||||
actionbarMessage(getLocaleKey('submit.ddl.1'));
|
||||
));
|
||||
if (dt == 600, (
|
||||
actionbarMessage('[WARN] Submission deadline in 30 seconds.');
|
||||
actionbarMessage(str(getLocaleKey('submit.ddl.2'), 30));
|
||||
));
|
||||
if (dt == 300, (
|
||||
actionbarMessage('[WARN] Submission deadline in 15 seconds.');
|
||||
actionbarMessage(str(getLocaleKey('submit.ddl.2'), 15));
|
||||
));
|
||||
if (dt <= 200 && dt % 20 == 0, (
|
||||
actionbarMessage(str('[WARN] Submission deadline in %d second%s!'
|
||||
, dt / 20, if(dt > 20, 's', '')));
|
||||
actionbarMessage(str(getLocaleKey(if(dt > 20, 'submit.ddl.2'
|
||||
, 'submit.ddl.3')), dt / 20));
|
||||
));
|
||||
);
|
||||
|
||||
@ -153,26 +157,27 @@ electionKill(pname) -> (
|
||||
modify(p, 'tag', 'ica.deceased');
|
||||
modify(p, 'gamemode', 'spectator');
|
||||
));
|
||||
print(player('all'), str('Election victim %s killed.', pname))
|
||||
print(player('all'), str(getLocaleKey('election.kill'), pname))
|
||||
);
|
||||
|
||||
checkVotes(tm) -> (
|
||||
if(tm % 12000 == 3600, (
|
||||
actionbarMessage('[WARN] Vote ends in 1 minute');
|
||||
actionbarMessage(getLocaleKey('election.ddl'));
|
||||
return(false);
|
||||
));
|
||||
if(tm % 12000 == 2400, (
|
||||
max_p = findVoteMax();
|
||||
phint = if(max_p == null, (
|
||||
'nobody was elected'
|
||||
getLocaleKey('election.result.nobody')
|
||||
), (
|
||||
ele_p = player(max_p);
|
||||
schedule(200, 'electionKill', ele_p);
|
||||
print(ele_p, '[WARN] You were elected! You will be killed in 10 seconds.');
|
||||
str('elected player %s', max_p)
|
||||
print(ele_p, getLocaleKey('election.result.kill'));
|
||||
max_p
|
||||
));
|
||||
resetVotes();
|
||||
print(player('all'), str('Election result: %s.\nNew eletion round started.', phint));
|
||||
print(player('all'), str(getLocaleKey('election.result'), phint));
|
||||
print(player('all'), getLocaleKey('election.new'))
|
||||
));
|
||||
);
|
||||
|
||||
@ -196,8 +201,10 @@ startCollectStage() -> (
|
||||
schedule(20, 'runUpdateCollect');
|
||||
|
||||
clearBossbars();
|
||||
createBossbar('ica:time_counter', 'Time Left', tm_total(), 'notched_6');
|
||||
createBossbar('ica:collected', 'Collected', 6, 'notched_6');
|
||||
createBossbar('ica:time_counter', format(getLocaleKey('bossbar.time.title'))
|
||||
, tm_total(), 'notched_6');
|
||||
createBossbar('ica:collected', format(getLocaleKey('bossbar.progress.title'))
|
||||
, 6, 'notched_6');
|
||||
bossbar('ica:collected', 'value', 0);
|
||||
|
||||
for(player('all'), (
|
||||
@ -238,7 +245,7 @@ cmdResetClear() -> (
|
||||
|
||||
cmdReschedule() -> (
|
||||
if(!nbt_storage('ica:data'):'Started', (
|
||||
print('Not started. use /ica-admin confirm to start.');
|
||||
print(format(getLocaleKey('reject.pending')));
|
||||
return(false)
|
||||
));
|
||||
schedule('runUpdateCollect', 20);
|
||||
@ -259,12 +266,12 @@ runUpdatePrepare() -> (
|
||||
cmdStart() -> (
|
||||
missing_goal = getFirstUnsetGoal();
|
||||
if(missing_goal <= 5, (
|
||||
print(str('Goal #%d is unset.', missing_goal));
|
||||
print(str(getLocaleKey('reject.goal.missing'), missing_goal));
|
||||
return(false)
|
||||
));
|
||||
|
||||
if(nbt_storage('ica:data'):'Started', (
|
||||
print('Already started, use /ica-admin reset clear to cancel.');
|
||||
print(format(getLocaleKey('reject.started')));
|
||||
return(false)
|
||||
));
|
||||
|
||||
@ -275,7 +282,7 @@ cmdStart() -> (
|
||||
builder_n = countCareer('builder') + hunter_n;
|
||||
firework_hunter_n = countCareer('firework_hunter') + builder_n;
|
||||
if(firework_hunter_n > length(participants_list), (
|
||||
print('Not enough players online.');
|
||||
print(format(getLocaleKey('reject.leckplayer')));
|
||||
return(false);
|
||||
));
|
||||
|
||||
@ -283,7 +290,8 @@ cmdStart() -> (
|
||||
put(nbt_storage('ica:data'):'Preparing', '1b');
|
||||
put(nbt_storage('ica:data'):'Goals[].Completed', '0b');
|
||||
|
||||
createBossbar('ica:prepare_counter', 'Preparing', tm_prepare(), null);
|
||||
createBossbar('ica:prepare_counter', format(getLocaleKey('bossbar.prepare.title'))
|
||||
, tm_prepare(), null);
|
||||
schedule(20, 'runUpdatePrepare');
|
||||
|
||||
cleanPlayerTags();
|
||||
@ -292,7 +300,7 @@ cmdStart() -> (
|
||||
for(participants_list, (
|
||||
modify(_, 'tag', ['ica.voter', 'ica.flyer', 'ica.participant']);
|
||||
career_tag = 'ica.piggy';
|
||||
if(_i < firework_hunter_n, career_tag = ['ica.hunter_firework', 'ica.firework_spyglasser', 'ica.spyglasser_cooldown']);
|
||||
if(_i < firework_hunter_n, career_tag = ['ica.firework_hunter', 'ica.firework_spyglasser', 'ica.spyglasser_cooldown']);
|
||||
if(_i < builder_n, career_tag = ['ica.builder', 'ica.build_spyglasser']);
|
||||
if(_i < hunter_n, career_tag = ['ica.hunter', 'ica.fireball_spyglasser', 'ica.spyglasser_cooldown']);
|
||||
if(_i < wolf_n, career_tag = ['ica.wolf', 'ica.fireball_spyglasser', 'ica.firework_spyglasser', 'ica.build_spyglasser', 'ica.coordinator']);
|
||||
@ -308,10 +316,10 @@ cmdStart() -> (
|
||||
run('gamerule keepInventory true');
|
||||
run('gamerule playersSleepingPercentage 0');
|
||||
run('gamerule randomTickSpeed 12');
|
||||
run('worldborder set 10000');
|
||||
run('worldborder set 20000');
|
||||
);
|
||||
|
||||
cmdList() -> (
|
||||
print('please use /ica instead');
|
||||
print(format(getLocaleKey('instead')));
|
||||
run('/ica');
|
||||
);
|
||||
|
125
src/ica-i18n.sc
Normal file
125
src/ica-i18n.sc
Normal file
@ -0,0 +1,125 @@
|
||||
__config() -> {
|
||||
'scope' -> 'global',
|
||||
'exports' -> ['getLocaleKey'],
|
||||
};
|
||||
|
||||
global_TranslateKeysEnUS = {
|
||||
'pig.timeout.title' -> 'Timeout!',
|
||||
'pig.timeout.subtitle' -> 'You didn\'t complete %d goals in time',
|
||||
'wolf.timeout.title' -> 'You won!',
|
||||
'wolf.timeout.subtitle' -> 'Those fools have failed, good job',
|
||||
|
||||
'pig.complete.title' -> 'Congratulations!',
|
||||
'pig.complete.subtitle' -> 'You have completed all the goals',
|
||||
'wolf.complete.title' -> 'Oh no!',
|
||||
'wolf.complete.subtitle' -> 'They have completed all the goals',
|
||||
|
||||
'submit.ddl.1' -> '[WARN] Submission deadline in 1 minute.',
|
||||
'submit.ddl.2' -> '[WARN] Submission deadline in %d seconds.',
|
||||
'submit.ddl.3' -> '[WARN] Submission deadline in %d second.',
|
||||
'submit.success' -> 'OK.',
|
||||
'submit.missing.before' -> ' Item ',
|
||||
'submit.missing.after' -> ' not found.',
|
||||
'submit.already.before' -> ' Item ',
|
||||
'submit.already.after' -> ' has already been collected.',
|
||||
|
||||
'election.kill' -> 'Election victim %s killed.',
|
||||
'election.ddl' -> '[WARN] Vote ends in 1 minute.',
|
||||
'election.result.nobody' -> 'nobody was elected',
|
||||
'election.result.kill' -> '[WARN] You were elected! You will be killed in 10 seconds.',
|
||||
'election.new' -> 'New election round started.',
|
||||
'election.result' -> 'Election result: %s.',
|
||||
|
||||
'instead' -> 'd Please use /ica instead.',
|
||||
|
||||
'bossbar.prepare.title' -> 'b Preparing',
|
||||
'bossbar.time.title' -> 'b Time Left',
|
||||
'bossbar.progress.title' -> 'b Collected',
|
||||
|
||||
'career.display.title' -> 'Career configs are:',
|
||||
'career.display.wolf' -> ' - Wolf: %d participants.',
|
||||
'career.display.hunter' -> ' - Hunter(Fireball): %d participants.',
|
||||
'career.display.firework_hunter' -> ' - Hunter(Firework): %d participants.',
|
||||
'career.display.builder' -> ' - Builder: %d participants.',
|
||||
'career.display.piggy' -> 'Career configs are:',
|
||||
'career.set' -> 'Career %s set to %d participants.',
|
||||
|
||||
'career.title.bystander' -> 'Bystander',
|
||||
'career.title.piggy' -> 'Piggy',
|
||||
'career.title.hunter' -> 'Hunter(Fireball)',
|
||||
'career.title.firework_hunter' -> 'Hunter(Firework)',
|
||||
'career.title.builder' -> 'Builder',
|
||||
'career.title.wolf' -> 'Wolf',
|
||||
|
||||
'career.help.bystander' -> 'You have nothing to do, just watch.',
|
||||
'career.help.piggy' -> 'Complete all goals in time to win!',
|
||||
'career.help.hunter' -> 'Protect piggies and kill the wolf.',
|
||||
'career.help.firework_hunter' -> 'Protect piggies and kill the wolf.',
|
||||
'career.help.builder' -> 'Build protections and complete the goals!',
|
||||
'career.help.wolf' -> 'Hide yourself and stop them to complete the goals!',
|
||||
|
||||
'career.whoami' -> 'You are %s: %s',
|
||||
|
||||
'ablity.title.voter' -> 'Voter',
|
||||
'ablity.title.flyer' -> 'Flyer',
|
||||
'ablity.title.fireball_spyglasser' -> 'Shooter',
|
||||
'ablity.title.firework_spyglasser' -> 'Launcher',
|
||||
'ablity.title.build_spyglasser' -> 'Builder',
|
||||
'ablity.title.coordinator' -> 'Coordinator',
|
||||
|
||||
'ablity.help.voter' -> 'You can vote.',
|
||||
'ablity.help.flyer' -> 'You can fly with an elytra.',
|
||||
'ablity.help.fireball_spyglasser' -> 'You can shoot fireballs with a spyglass(except prepare stage).',
|
||||
'ablity.help.firework_spyglasser' -> 'You can launch fireworks with a spyglass(except prepare stage).',
|
||||
'ablity.help.build_spyglasser' -> 'You can build paths with a spyglass(except prepare stage).',
|
||||
'ablity.help.coordinator' -> 'You can locate other participants.',
|
||||
|
||||
'ablity.format' -> '[ablity] %s: %s',
|
||||
|
||||
'reject.pending' -> [' Not started. use ', 'mb /ica-admin confirm', '?/ica-admin confirm', ' to start.'],
|
||||
'reject.started' -> [' Already started, use ', 'mb /ica-admin reset clear', '?/ica-admin reset clear', ' to cancel.'],
|
||||
'reject.leckplayer' -> ' Not enough players are online.',
|
||||
'reject.goal.missing' -> 'Goal #%d is unset.',
|
||||
'reject.goal.enough' -> [' All are goals set, please use ', 'mb /ica-settings set <slot> <item>', ' to replace.'],
|
||||
'reject.spyglass' -> 'Spyglass too hot, please wait another %.2f seconds to use again.',
|
||||
'reject.unable' -> 'You don\'t have this ability.',
|
||||
'reject.bystand' -> 'You can only bystand.',
|
||||
'reject.reparing.submit' -> 'Currently preparing, please submit later.',
|
||||
'reject.reparing.switch' -> 'Currently preparing, please switch later.',
|
||||
|
||||
'list.title.pending' -> 'Pending:',
|
||||
'list.title.collecting' -> 'Collecting, %d seconds left, %d are goals done:',
|
||||
'list.title.preparing' -> 'Perparing, %d seconds to collect stage:',
|
||||
'list.item.unset' -> 'unset',
|
||||
'list.item.submit' -> '[Click To Submit]',
|
||||
'list.marker.0' -> ' - ',
|
||||
'list.marker.1' -> ' + ',
|
||||
'list.item.id' -> '#%d: ',
|
||||
|
||||
'vote.title' -> 'There are %d candidates:',
|
||||
'vote.deceased' -> '[deceased]',
|
||||
'vote.amount.1' -> '[%02d vote]',
|
||||
'vote.amount.2' -> '[%02d votes]',
|
||||
'vote.footer' -> 'Current elected: ',
|
||||
'vote.nobody' -> '(nobody)',
|
||||
'vote.abstain' -> '(abstain)',
|
||||
'vote.button.vote' -> '[Click To Vote]',
|
||||
'vote.button.abstain' -> '[Click To Abstain]',
|
||||
'vote.marker' -> ' - ',
|
||||
'vote.already' -> 'You have already voted.',
|
||||
'vote.notfound' -> 'Candidate %s not found.',
|
||||
'vote.success' -> 'OK.',
|
||||
|
||||
'locate.notfound' -> 'Player %s not found.',
|
||||
'locate.offline' -> 'Player %s is not online.',
|
||||
|
||||
'seed.title' -> 'Map Seed: ',
|
||||
|
||||
'misc.clipboard' -> 'Click To Copy',
|
||||
|
||||
'license.header' -> 'ICollect-Alpha, Copyright (C) 2023 方而静\nICollect-Alpha comes with ABSOLUTELY NO WARRANTY;\nfor details type \'/ica-loader show w\'.\nThis is free software, and you are welcome to redistribute it\nunder certain conditions; type \'/ica-loader show c\' for details.',
|
||||
};
|
||||
|
||||
getLocaleKey(keyid) -> (
|
||||
if(has(global_TranslateKeysEnUS:keyid), global_TranslateKeysEnUS:keyid, 'tkey:' + keyid)
|
||||
);
|
@ -8,9 +8,7 @@ __config() -> {
|
||||
},
|
||||
};
|
||||
|
||||
licenseHeader() -> (
|
||||
'ICollect-Alpha, Copyright (C) 2023 方而静\nICollect-Alpha comes with ABSOLUTELY NO WARRANTY;\nfor details type \'/ica-loader show w\'.\nThis is free software, and you are welcome to redistribute it\nunder certain conditions; type \'/ica-loader show c\' for details.'
|
||||
);
|
||||
import('ica-i18n', 'getLocaleKey');
|
||||
|
||||
WarrantyInfo() -> (
|
||||
'NO WARRANTY\n 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\nFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN\nOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\nPROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\nOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS\nTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE\nPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\nREPAIR OR CORRECTION.\n\n 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\nREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\nINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\nOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\nTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\nYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\nPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGES.\n'
|
||||
@ -21,7 +19,7 @@ CopyrightInfo() -> (
|
||||
);
|
||||
|
||||
cmdLoad() -> (
|
||||
print(licenseHeader());
|
||||
print(getLocaleKey('license.header'));
|
||||
run('script load ica-admin');
|
||||
run('script load ica-effect-applier');
|
||||
run('script load ica-spyglass');
|
||||
|
@ -18,6 +18,7 @@ __config() -> {
|
||||
},
|
||||
};
|
||||
|
||||
import('ica-i18n', 'getLocaleKey');
|
||||
import('ica-libs', 'countCareer');
|
||||
|
||||
getFirstUnsetGoal() -> (
|
||||
@ -31,13 +32,13 @@ getFirstUnsetGoal() -> (
|
||||
);
|
||||
|
||||
cmdList() -> (
|
||||
print('please use /ica instead');
|
||||
print(format(getLocaleKey('instead')));
|
||||
run('/ica');
|
||||
);
|
||||
|
||||
cmdSet(slot_id, goal_item_tuple) -> (
|
||||
if(nbt_storage('ica:data'):'Started', (
|
||||
print('Already started, use /ica-admin reset clear to cancel.');
|
||||
print(format(getLocaleKey('reject.started')));
|
||||
return(false)
|
||||
));
|
||||
pkey = str('Goals[{Slot: %db}]', slot_id);
|
||||
@ -53,20 +54,21 @@ cmdSetAppend(goal_item_tuple) -> (
|
||||
if(missing_goal <= 5, (
|
||||
cmdSet(missing_goal, goal_item_tuple)
|
||||
), (
|
||||
print('All are goals set, please use /ica-settings set <slot> <item>.')
|
||||
print(format(getLocaleKey('reject.goal.enough')))
|
||||
));
|
||||
);
|
||||
|
||||
cmdListCareers() -> (
|
||||
print('Career configs are:');
|
||||
print(str(' - Wolf: %d participants.', countCareer('wolf')));
|
||||
print(str(' - Hunter: %d participants.', countCareer('hunter')));
|
||||
print(' - Piggy: Whatever the rest.');
|
||||
print(getLocaleKey('career.display.title'));
|
||||
for(['wolf', 'hunter', 'firework_hunter', 'builder'], (
|
||||
print(str(getLocaleKey('career.display.' + _), countCareer(_)));
|
||||
));
|
||||
print(getLocaleKey('career.display.piggy'));
|
||||
);
|
||||
|
||||
cmdConfigCareer(cartype, ccount) -> (
|
||||
if(nbt_storage('ica:data'):'Started', (
|
||||
print('Already started, use /ica-admin reset clear to cancel.');
|
||||
print(format(getLocaleKey('reject.started')));
|
||||
return(false)
|
||||
));
|
||||
pkey = str('Config[{Type: "%s"}].Count', cartype);
|
||||
@ -74,5 +76,5 @@ cmdConfigCareer(cartype, ccount) -> (
|
||||
|
||||
if(nbt_storage('ica:careers'):pkey != null, delete(nbt_storage('ica:careers'):pkey));
|
||||
put(nbt_storage('ica:careers'), 'Config', etag, -1);
|
||||
print(str('Career %s set to %d participants.', cartype, ccount))
|
||||
print(str(getLocaleKey('career.set'), cartype, ccount))
|
||||
);
|
||||
|
@ -1,3 +1,6 @@
|
||||
|
||||
import('ica-i18n', 'getLocaleKey');
|
||||
|
||||
global_lastUseSpyglass = -500;
|
||||
|
||||
shootFireball(myself) -> (
|
||||
@ -47,8 +50,7 @@ checkCooldown(myself) -> (
|
||||
if(query(myself, 'has_scoreboard_tag', 'ica.spyglasser_cooldown')
|
||||
&& dt < 100, (
|
||||
display_title(player(), 'actionbar'
|
||||
, str('spyglass too hot, please wait another %.2f seconds to shoot again.'
|
||||
, (100 - dt) / 20.0), 100, 100, 100);
|
||||
, str(getLocaleKey('reject.spyglass'), (100 - dt) / 20.0));
|
||||
return(true);
|
||||
));
|
||||
global_lastUseSpyglass = nowTT;
|
||||
|
@ -17,46 +17,61 @@ __config() -> {
|
||||
};
|
||||
|
||||
import('ica-libs', 'listContain', 'countVotes', 'findVoteMax', 'countAbstainVotes');
|
||||
|
||||
import('ica-i18n', 'getLocaleKey');
|
||||
|
||||
cmdInfo() -> (
|
||||
if(!nbt_storage('ica:data'):'Started', (
|
||||
print('Not started. use /ica-admin confirm to start.');
|
||||
print(format(getLocaleKey('reject.pending')));
|
||||
return(false)
|
||||
));
|
||||
cand_names = parse_nbt(nbt_storage('ica:voting'):'Candidates');
|
||||
cand_n = length(cand_names);
|
||||
print(str('There are %d candidates:', cand_n));
|
||||
print(str(getLocaleKey('vote.title', cand_n));
|
||||
for(cand_names, (
|
||||
p = player(_);
|
||||
v_cnt = countVotes(_);
|
||||
print(str(' - [%02d vote%s] %s%s', v_cnt, if(v_cnt > 1, 's', ' ')
|
||||
, _, if(query(p, 'has_scoreboard_tag', 'ica.deceased'), ' [deceased]', '')));
|
||||
if(query(p, 'has_scoreboard_tag', 'ica.deceased'), (
|
||||
print(format(' ' + getLocaleKey('vote.marker')
|
||||
+ str(getLocaleKey('vote.amount.' + if(v_cnt > 1, '2', '1')), v_cnt)
|
||||
, 's ' + _
|
||||
, 'n ') + getLocaleKey('vote.deceased'));
|
||||
), (
|
||||
print(format(' ' + getLocaleKey('vote.marker')
|
||||
+ str(getLocaleKey('vote.amount.' + if(v_cnt > 1, '2', '1')), v_cnt)
|
||||
, 'b ' + _
|
||||
, 'mb' + getLocaleKey('vote.button.vote')
|
||||
, '!/ica-vote sus ' + _));
|
||||
));
|
||||
));
|
||||
abv_cnt = countAbstainVotes();
|
||||
print(str(' - [%2d vote%s] (abstain)', abv_cnt, if(abv_cnt > 1, 's', ' ')));
|
||||
print(format(' ' + getLocaleKey('vote.marker')
|
||||
+ str(getLocaleKey('vote.amount.' + if(abv_cnt > 1, '2', '1')), abv_cnt)
|
||||
, 'gb ' + getLocaleKey('vote.abstain')
|
||||
, 'mb' + getLocaleKey('vote.button.abstain')
|
||||
, '!/ica-vote abstain'));
|
||||
|
||||
max_p = findVoteMax();
|
||||
print(str('Current elected: %s', if(max_p == null, '(nobody)', max_p)));
|
||||
print(format(' ' + getLocaleKey('vote.footer')
|
||||
, if(max_p == null, 'gi ' + getLocaleKey('vote.nobody'), 'b ' + max_p)));
|
||||
);
|
||||
|
||||
beforeVoteChecks() -> (
|
||||
if(!nbt_storage('ica:data'):'Started', (
|
||||
print('Not started. use /ica-admin confirm to start.');
|
||||
print(format(getLocaleKey('reject.pending')));
|
||||
return(false)
|
||||
));
|
||||
myself = player();
|
||||
if(query(myself, 'has_scoreboard_tag', 'ica.deceased'), (
|
||||
print('You can only bystand.');
|
||||
print(getLocaleKey('reject.bystand'));
|
||||
return(false);
|
||||
));
|
||||
if(!query(myself, 'has_scoreboard_tag', 'ica.voter'), (
|
||||
print('You don\'t have this ability');
|
||||
print(getLocaleKey('reject.unable'));
|
||||
return(false);
|
||||
));
|
||||
myname = query(myself, 'command_name');
|
||||
if(has(nbt_storage('ica:voting'), str('Votes[{From: "%s"}]', myname)), (
|
||||
print('You have already voted.');
|
||||
print(getLocaleKey('vote.already'));
|
||||
return(false);
|
||||
));
|
||||
true
|
||||
@ -67,7 +82,7 @@ cmdVotePlayer(sus_name) -> (
|
||||
|
||||
cand_names = parse_nbt(nbt_storage('ica:voting'):'Candidates');
|
||||
if(!listContain(cand_names, sus_name), (
|
||||
print(str('Candidate %s not found.', sus_name));
|
||||
print(str(getLocaleKey('vote.notfound'), sus_name));
|
||||
return(false);
|
||||
));
|
||||
|
||||
@ -76,7 +91,7 @@ cmdVotePlayer(sus_name) -> (
|
||||
|
||||
etags = nbt(str('{From: "%s", To: "%s", Abstain: 0b}', myname, sus_name));
|
||||
put(nbt_storage('ica:voting'), 'Votes', etags, -1);
|
||||
print('OK.');
|
||||
print(getLocaleKey('vote.success'));
|
||||
);
|
||||
|
||||
cmdVoteAbstain() -> (
|
||||
@ -86,5 +101,5 @@ cmdVoteAbstain() -> (
|
||||
|
||||
etags = nbt(str('{From: "%s", To: "", Abstain: 1b}', myname));
|
||||
put(nbt_storage('ica:voting'), 'Votes', etags, -1);
|
||||
print('OK.');
|
||||
print(getLocaleKey('vote.success'));
|
||||
);
|
||||
|
155
src/ica.sc
155
src/ica.sc
@ -13,12 +13,20 @@ __config() -> {
|
||||
'arguments' -> {
|
||||
'slot' -> { 'type' -> 'int', 'min' -> 0, 'max' -> 5
|
||||
, 'suggest' -> [0, 1, 2, 3, 4, 5] },
|
||||
'participant' -> { 'type' -> 'players' },
|
||||
'participant' -> { 'type' -> 'string', 'suggester' -> _(arg) -> (
|
||||
if(nbt_storage('ica:data'):'Started',
|
||||
parse_nbt(nbt_storage('ica:voting'):'Candidates'),
|
||||
[]
|
||||
)
|
||||
)},
|
||||
'spyglass_feature' -> { 'type' -> 'string',
|
||||
'options' -> [ 'builder', 'firework', 'fireball' ] }
|
||||
}
|
||||
};
|
||||
|
||||
import('ica-libs', 'listContain');
|
||||
import('ica-i18n', 'getLocaleKey');
|
||||
|
||||
global_capMarkerMap = {
|
||||
'builder' -> 'ica.build_spyglasser',
|
||||
'fireball' -> 'ica.fireball_spyglasser',
|
||||
@ -34,16 +42,16 @@ tm_per_goal() -> (
|
||||
);
|
||||
|
||||
lackOfAbilityReject() -> (
|
||||
display_title(player(), 'actionbar', 'You don\'t have this ability.');
|
||||
print(getLocaleKey('reject.unable'));
|
||||
);
|
||||
|
||||
bystandReject() -> (
|
||||
display_title(player(), 'actionbar', 'You can only bystand.');
|
||||
print(getLocaleKey('reject.bystand'));
|
||||
);
|
||||
|
||||
cmdLocate(pname) -> (
|
||||
if(!nbt_storage('ica:data'):'Started', (
|
||||
print('Not started. use /ica-admin confirm to start.');
|
||||
print(format(getLocaleKey('reject.pending')));
|
||||
return(false)
|
||||
));
|
||||
myself = player();
|
||||
@ -56,9 +64,15 @@ cmdLocate(pname) -> (
|
||||
return(false);
|
||||
));
|
||||
|
||||
p = player(pname:0);
|
||||
cand_names = parse_nbt(nbt_storage('ica:voting'):'Candidates');
|
||||
if(!listContain(cand_names, pname), (
|
||||
print(str(getLocaleKey('locate.notfound'), pname));
|
||||
return(false);
|
||||
));
|
||||
|
||||
p = player(pname);
|
||||
if(p == null, (
|
||||
print('Not found');
|
||||
print(str(getLocaleKey('locate.offline'), pname));
|
||||
return(false);
|
||||
));
|
||||
|
||||
@ -80,17 +94,19 @@ cmdLocate(pname) -> (
|
||||
);
|
||||
|
||||
cmdSeed() -> (
|
||||
print(str('%s: %d', system_info('world_name'), system_info('world_seed')));
|
||||
seed_val = str(system_info('world_seed'));
|
||||
print(format(' ' + getLocaleKey('seed.title')
|
||||
, 'c ' + seed_val, '&' + seed_val, '^ ' + getLocaleKey('misc.clipboard')));
|
||||
);
|
||||
|
||||
cmdRefill() -> (
|
||||
if(!nbt_storage('ica:data'):'Started', (
|
||||
print('Not started. use /ica-admin confirm to start.');
|
||||
print(format(getLocaleKey('reject.pending')));
|
||||
return(false)
|
||||
));
|
||||
myself = player();
|
||||
if(query(myself, 'has_scoreboard_tag', 'ica.deceased'), (
|
||||
print('You can only bystand.');
|
||||
bystandReject();
|
||||
return(false);
|
||||
));
|
||||
if(query(myself, 'has_scoreboard_tag', 'ica.flyer'), (
|
||||
@ -101,81 +117,72 @@ cmdRefill() -> (
|
||||
cmdList() -> (
|
||||
if(nbt_storage('ica:data'):'Started', (
|
||||
if(!nbt_storage('ica:data'):'Preparing', (
|
||||
print(str('Collecting, %d seconds left, %d are goals done:',
|
||||
bossbar('ica:time_counter', 'value') / 20,
|
||||
bossbar('ica:collected', 'value')));
|
||||
print(str(getLocaleKey('list.title.collecting')
|
||||
, bossbar('ica:time_counter', 'value') / 20
|
||||
, bossbar('ica:collected', 'value')));
|
||||
), (
|
||||
print(str('Perparing, %d seconds to collect:'
|
||||
print(str(getLocaleKey('list.title.preparing')
|
||||
, bossbar('ica:prepare_counter', 'value') / 20));
|
||||
));
|
||||
), (
|
||||
print('Pending:');
|
||||
print(getLocaleKey('list.title.pending'));
|
||||
));
|
||||
|
||||
c_for(i = 0, i <= 5, i = i + 1, (
|
||||
p = nbt_storage('ica:data'):str('Goals[{Slot: %db}]', i);
|
||||
if(p == null, (
|
||||
print(str('- #%d: unset', i));
|
||||
print(format(' ' + getLocaleKey('list.marker.0')
|
||||
+ str(getLocaleKey('list.item.id'), i)
|
||||
, 'gi ' + getLocaleKey('list.item.unset')));
|
||||
), (
|
||||
print(str('%s #%d: %s(%s)', if(nbt_storage('ica:data'):'Started' && p:'Completed', '+', '-')
|
||||
, i, item_display_name(p:'Item'), p:'Item'))
|
||||
))
|
||||
if(nbt_storage('ica:data'):'Started' && p:'Completed', (
|
||||
print(format(' ' + getLocaleKey('list.marker.1')
|
||||
+ str(getLocaleKey('list.item.id'), i)
|
||||
, 's ' + item_display_name(p:'Item')
|
||||
, '^ minecraft:' + p:'Item'));
|
||||
), (
|
||||
if(nbt_storage('ica:data'):'Started' && !nbt_storage('ica:data'):'Preparing', (
|
||||
print(format(' ' + getLocaleKey('list.marker.0')
|
||||
+ str(getLocaleKey('list.item.id'), i)
|
||||
, 'b ' + item_display_name(p:'Item')
|
||||
, '^ minecraft:' + p:'Item'
|
||||
, ' '
|
||||
, 'mb ' + getLocaleKey('list.item.submit')
|
||||
, '!/ica submit ' + str(i)));
|
||||
), (
|
||||
print(format(' ' + getLocaleKey('list.marker.0')
|
||||
+ str(getLocaleKey('list.item.id'), i)
|
||||
, 'b ' + item_display_name(p:'Item')
|
||||
, '^ minecraft:' + p:'Item'));
|
||||
));
|
||||
))
|
||||
));
|
||||
));
|
||||
);
|
||||
|
||||
cmdMe() -> (
|
||||
if(!nbt_storage('ica:data'):'Started', (
|
||||
print('Not started. use /ica-admin confirm to start.');
|
||||
print(format(getLocaleKey('reject.pending')));
|
||||
return(false)
|
||||
));
|
||||
myself = player();
|
||||
career_hints = {
|
||||
'Bystander' -> 'You have nothing to do, just watch.',
|
||||
'Piggy' -> 'Complete all goals in time to win!',
|
||||
'Hunter(Fireball)' -> 'Protect piggies and kill the wolf.',
|
||||
'Hunter(Firework)' -> 'Protect piggies and kill the wolf.',
|
||||
'Builder' -> 'Build protections and complete the goals!',
|
||||
'Wolf' -> 'Stop them completing the goals!',
|
||||
};
|
||||
career = 'Bystander';
|
||||
|
||||
if(query(myself, 'has_scoreboard_tag', 'ica.piggy'), (
|
||||
career = 'Piggy';
|
||||
career = 'bystander';
|
||||
for(['piggy', 'hunter', 'firework_hunter', 'builder', 'wolf'], (
|
||||
if(query(myself, 'has_scoreboard_tag', 'ica.' + _), (
|
||||
career = _;
|
||||
));
|
||||
));
|
||||
if(query(myself, 'has_scoreboard_tag', 'ica.hunter'), (
|
||||
career = 'Hunter(Fireball)';
|
||||
));
|
||||
if(query(myself, 'has_scoreboard_tag', 'ica.hunter_firework'), (
|
||||
career = 'Hunter(Firework)';
|
||||
));
|
||||
if(query(myself, 'has_scoreboard_tag', 'ica.builder'), (
|
||||
career = 'Builder';
|
||||
));
|
||||
if(query(myself, 'has_scoreboard_tag', 'ica.wolf'), (
|
||||
career = 'Wolf';
|
||||
));
|
||||
print(str('You are "%s": %s', career, career_hints:career));
|
||||
|
||||
if(query(myself, 'has_scoreboard_tag', 'ica.voter'), (
|
||||
print('[ability] voter: you can vote.');
|
||||
));
|
||||
if(query(myself, 'has_scoreboard_tag', 'ica.flyer'), (
|
||||
print('[ability] flyer: you can fly with an elytra.');
|
||||
));
|
||||
if(query(myself, 'has_scoreboard_tag', 'ica.fireball_spyglasser'), (
|
||||
print('[ability] shooter: You can shoot fireballs with a spyglass(except in prepare stage).');
|
||||
));
|
||||
if(query(myself, 'has_scoreboard_tag', 'ica.firework_spyglasser'), (
|
||||
print('[ability] launcher: You can launch fireworks with a spyglass(except in prepare stage).');
|
||||
));
|
||||
if(query(myself, 'has_scoreboard_tag', 'ica.build_spyglasser'), (
|
||||
print('[ability] builder: You can build paths with a spyglass(except in prepare stage).');
|
||||
));
|
||||
// if(query(myself, 'has_scoreboard_tag', 'ica.kungfu_master'), (
|
||||
// print('[ability] kungfu master: You can get a temporary slow-falling effect by using a feather.');
|
||||
// ));
|
||||
if(query(myself, 'has_scoreboard_tag', 'ica.coordinator'), (
|
||||
print('[ability] coordinator: you can locate other participants.');
|
||||
print(str(getLocaleKey('career.whoami'), getLocaleKey('career.title.' + career)
|
||||
, getLocaleKey('career.help.' + career)));
|
||||
|
||||
for(['voter', 'flyer', 'fireball_spyglasser', 'firework_spyglasser'
|
||||
, 'build_spyglasser', 'coordinator'], (
|
||||
if(query(myself, 'has_scoreboard_tag', 'ica.' + _), (
|
||||
print(str(getLocaleKey('ablity.format')
|
||||
, getLocaleKey('ablity.title.' + _), getLocaleKey('ablity.help.' + _)));
|
||||
));
|
||||
));
|
||||
);
|
||||
|
||||
@ -186,12 +193,12 @@ disableAllSpyglassAbilities(me) -> (
|
||||
|
||||
cmdSpyglassSwitch(feature_id) -> (
|
||||
if(!nbt_storage('ica:data'):'Started', (
|
||||
print('Not started. use /ica-admin confirm to start.');
|
||||
print(format(getLocaleKey('reject.pending')));
|
||||
return(false)
|
||||
));
|
||||
me = player();
|
||||
if(nbt_storage('ica:data'):'Preparing', (
|
||||
display_title(me, 'actionbar', 'Currently preparing, please switch later.');
|
||||
print(getLocaleKey('reject.reparing.switch'));
|
||||
return(false)
|
||||
));
|
||||
if(query(me, 'has_scoreboard_tag', 'ica.deceased'), (
|
||||
@ -209,33 +216,35 @@ cmdSpyglassSwitch(feature_id) -> (
|
||||
|
||||
cmdSubmit(slot_id) -> (
|
||||
if(!nbt_storage('ica:data'):'Started', (
|
||||
print('Not started. use /ica-admin confirm to start.');
|
||||
print(format(getLocaleKey('reject.pending')));
|
||||
return(false)
|
||||
));
|
||||
if(nbt_storage('ica:data'):'Preparing', (
|
||||
print('Currently preparing, please submit later.');
|
||||
print(getLocaleKey('reject.reparing.submit'));
|
||||
return(false)
|
||||
));
|
||||
me = player();
|
||||
if(query(me, 'has_scoreboard_tag', 'ica.deceased'), (
|
||||
print('You can only bystand.');
|
||||
bystandReject();
|
||||
return(false);
|
||||
));
|
||||
|
||||
pkey = str('Goals[{Slot: %db}]', slot_id);
|
||||
if(nbt_storage('ica:data'):pkey:'Completed', (
|
||||
print(str('%s has already been collected.', item_display_name(
|
||||
nbt_storage('ica:data'):pkey:'Item')));
|
||||
print(format(getLocaleKey('submit.already.before'))
|
||||
+ item_display_name(nbt_storage('ica:data'):pkey:'Item')
|
||||
+ format(getLocaleKey('submit.already.after')));
|
||||
return()
|
||||
));
|
||||
|
||||
if(inventory_remove(me, nbt_storage('ica:data'):pkey:'Item', 1) == 0, (
|
||||
print(str('%s not found.', item_display_name(
|
||||
nbt_storage('ica:data'):pkey:'Item')));
|
||||
print(format(getLocaleKey('submit.missing.before'))
|
||||
+ item_display_name(nbt_storage('ica:data'):pkey:'Item')
|
||||
+ format(getLocaleKey('submit.missing.after')));
|
||||
return()
|
||||
));
|
||||
put(nbt_storage('ica:data'):(pkey+'.Completed'), '1b');
|
||||
iv = bossbar('ica:collected', 'value') + 1;
|
||||
bossbar('ica:collected', 'value', iv);
|
||||
display_title(me, 'actionbar', 'OK.');
|
||||
print(getLocaleKey('submit.success'));
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user