版本比较
拍拍游戏
正文
增加 222 行删除 2083 行
123456789101112131415161718192021221234567891011121314151617150 行未改动全部展开16816917017119017217317417517636 行未改动21321421521623521721821923822022122222322422522622724622822923024923123223323423510 行未改动24624724824926825025125225325413 行未改动2682692702712902722732742932752762772782795 行未改动28528628728830730828929031031131231331431531629129229329429529629729829930030110 行未改动312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508750 行未改动全部展开125912601261126210931263126412651266126768 行未改动13361337133813391340134113421343134413451346134713481349117613501351117813521353135413551356135713581359136013611362136313641365136613676 行未改动13741375137613771198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238总共有C++/HTML两个版本。
## 代码运行教程### C++下载DEV-C++ → 打开 DEV-C++ → 按下`CTRL+N` → 粘贴代码 → 按下`F11` → 保存(`.cpp`文件,如:`clap clap game.cpp`) → 在弹出的`.exe`文件上操作。
### HTML按下`WIN+R` → 输入`notepad` → 粘贴代码 → 保存(`.html`文件,注意要加双引号,如:`"clap clap game.html"`,保存类型选`所有文件`,编码选`UTF-8`) → 选择打开方式为浏览器(如:Google Chrome) → 双击打开。
## 存档### C++版本保存到与游戏的`.exe`程序同一个位置
### HTML版本1.自动保存,保存到浏览器中,无文件;2.点击`导出日志`按钮,存档文件下载至`此电脑 > 下载文件夹`中。
## 注意C++版本必须要使用`Windows`系统。
## 代码### C++版本```cpp line-numbers```cpp#include <iostream>#include <winsock2.h>#include <ws2tcpip.h>#include <windows.h>#include <vector>#include <ctime>#include <algorithm>#include <fstream>#include <string>#include <conio.h>#include <limits>#pragma comment(lib, "ws2_32.lib")using namespace std;ofstream logfile;
void log(const string& m) {150 行未改动全部展开 Sleep(100); cout << "5.超级自毙:消耗2颗子弹,造成2滴血伤害。当自己被自己造成伤害时,返回2颗子弹。\n"; Sleep(100); cout << "6.超级普攻可破普通反弹,双方造成1滴血伤害;可破防御,对方造成1滴血伤害。\n"; Sleep(3000); Sleep(2000); system("cls"); int a = 4, b = 4, c = 0, d = 0; string s[] = {"", "装子弹", "普攻", "反弹", "防御", "自毙", "超级普攻", "超级反弹", "超级防御", "超级自毙"}; log("=== 疯狂普通版游戏开始 ===");36 行未改动 else if (x == 2) a--, b--, d--; else if (x == 3) a--, d--; else if (x == 4) d--; else if (x == 5) b = 0; else if (x == 6) a--, b -= 2, d -= 2; else if (x == 6) a -= 2, b--, d -= 2; else if (x == 7) a--, d--; else if (x == 8) d -= 2; else if (x == 9) a--, b -= 2, d -= 2; else if (x == 9) b -= 3, d -= 2; } else if (op == 3) { c--; if (x == 1) d++; else if (x == 2) b--, d--; else if (x == 3) d--; else if (x == 4) d--; else if (x == 5) a--, d--; else if (x == 6) a--, d -= 2; else if (x == 6) a -= 2, d -= 2; else if (x == 7) b -= 2, d -= 2; else if (x == 8) d -= 2; else if (x == 9) a -= 2, d -= 2; else if (x == 9) b -= 2, d -= 2; } else if (op == 4) { c--; if (x == 1) d++; else if (x == 2) d--;10 行未改动 else if (x == 2) a = 0; else if (x == 3) b--, d--; else if (x == 4) a--, d--; else if (x == 5) a--, b--, d--; else if (x == 6) a--, d -= 2; else if (x == 6) a -= 3, d -= 2; else if (x == 7) a--, d--; else if (x == 8) a--, d -= 2; else if (x == 9) a = 0; } else if (op == 6) {13 行未改动 else if (x == 2) b--, c += 2, d--; else if (x == 3) c++, d--; else if (x == 4) c++, d--; else if (x == 5) b--, c += 2, d--; else if (x == 6) a--, c += 2, d -= 2; else if (x == 6) a -= 2, c += 2, d -= 2; else if (x == 7) c++, d -= 2; else if (x == 8) c++, d -= 2; else if (x == 9) b -= 2, c += 2, d -= 2; else if (x == 9) b -= 2, d += 2; } else if (op == 8) { c -= 2; if (x == 1) c++, d++; else if (x == 2) c++, d--;5 行未改动 else if (x == 8) c++, d -= 2; else if (x == 9) c++, d -= 2; } else if (op == 9) { c -= 2; a -= 2; if (x == 1) d++; if (x == 1) a -= 2, c += 2, d++; else if (x == 2) a = 0; else if (x == 3) d--; else if (x == 4) d--; else if (x == 5) b--, d--; else if (x == 6) d -= 2; else if (x == 7) d--; else if (x == 8) d -= 2; else if (x == 9) c += 2, d -= 2; else if (x == 3) a -= 2, c += 2, d--; else if (x == 4) a -= 2, c += 2, d--; else if (x == 5) a -= 2, c += 2, b--, d--; else if (x == 6) a -= 4, c += 2, d -= 2; else if (x == 7) b -= 2, d += 2; else if (x == 8) a -= 2, c += 2, d -= 2; else if (x == 9) a -= 2, c += 2, b -= 2, d += 2; }
log("玩家: " + s[op] + ", 对手: " + s[x] + ", 玩家血量: " + to_string(pa) + "->" + to_string(a) + ", 对手血量: " + to_string(pb) + "->" + to_string(b) + ", 子弹: " + to_string(pc) + "->" + to_string(c) + " / " + to_string(pd) + "->" + to_string(d)); cout << "\n你:" << s[op] + " 对方:" + s[x] + "\n\n" + "你的血量:" + to_string(a) + " 对方的血量:" + to_string(b);10 行未改动 log("=== 游戏结束 ==="); return;}
void f1vs_Create(){ WSADATA wsa; if (WSAStartup(MAKEWORD(2, 2), &wsa) != 0) { cout << "WSAStartup 失败\n"; _getch(); return; } SOCKET srv = socket(AF_INET, SOCK_STREAM, 0); sockaddr_in addr; addr.sin_family = AF_INET; addr.sin_addr.s_addr = INADDR_ANY; addr.sin_port = htons(8888); if (bind(srv, (sockaddr*)&addr, sizeof(addr)) == SOCKET_ERROR) { cout << "bind 失败,端口可能被占用\n"; closesocket(srv); WSACleanup(); _getch(); return; } listen(srv, 1); system("cls"); cout << "========== 双人联机(服务器) ==========\n\n"; cout << "等待玩家连接...\n"; SOCKET cli = accept(srv, NULL, NULL); if (cli == INVALID_SOCKET) { cout << "accept 失败\n"; closesocket(srv); WSACleanup(); _getch(); return; } int a = 2, b = 2, c = 0, d = 0; string s[] = {"", "装子弹", "普攻", "反弹", "防御", "自毙"}; while (a > 0 && b > 0) { system("cls"); cout << "========== 双人联机 - 你的回合 ==========\n\n"; cout << "你的血量:" << a << " 对方血量:" << b << "\n"; cout << "你的子弹:" << c << " 对方子弹:" << d << "\n\n"; int op = 1; if (c == 0) { cout << "无子弹,自动装子弹\n"; Sleep(1000); op = 1; } else { cout << "1.装子弹 2.普攻 3.反弹 4.防御 5.自毙\n"; do cin >> op; while (op < 1 || op > 5); } send(cli, (char*)&op, sizeof(op), 0); int x; recv(cli, (char*)&x, sizeof(x), 0); int pa = a, pb = b; if (op == 1) { if (x == 1) c++, d++; else if (x == 2) a--, c++, d--; else if (x == 3) c++, d--; else if (x == 4) c++, d--; else if (x == 5) b--, c++, d--; } else if (op == 2) { if (x == 1) b--, c--, d++; else if (x == 2) a--, b--, c--, d--; else if (x == 3) a--, c--, d--; else if (x == 4) c--, d--; else if (x == 5) b = 0; } else if (op == 3) { if (x == 1) c--, d++; else if (x == 2) b--, c--, d--; else if (x == 3) c--, d--; else if (x == 4) c--, d--; else if (x == 5) a--, c--, d--; } else if (op == 4) { if (x == 1) c--, d++; else if (x == 2) c--, d--; else if (x == 3) c--, d--; else if (x == 4) c--, d--; else if (x == 5) b--, c--, d--; } else if (op == 5) { if (x == 1) a--, c--, d++; else if (x == 2) a = 0; else if (x == 3) b--, c--, d--; else if (x == 4) a--, c--, d--; else if (x == 5) a--, b--, c--, d--; } log("联机 - 玩家1: " + s[op] + ", 玩家2: " + s[x] + ", 玩家1血量: " + to_string(pa) + "->" + to_string(a) + ", 玩家2血量: " + to_string(pb) + "->" + to_string(b)); cout << "\n你:" << s[op] << " 对方:" << s[x] << "\n\n"; cout << "你的血量:" << a << " 对方的血量:" << b; Sleep(3000); } system("cls"); if (a <= 0 && b <= 0) cout << "平局!\n"; else if (a <= 0) cout << "你输了!\n"; else cout << "你赢了!\n"; Sleep(2000); closesocket(cli); closesocket(srv); WSACleanup();}
void f1vs_Jion(){ WSADATA wsa; if (WSAStartup(MAKEWORD(2, 2), &wsa) != 0) { cout << "WSAStartup 失败\n"; _getch(); return; } SOCKET sock = socket(AF_INET, SOCK_STREAM, 0); system("cls"); cout << "========== 猜拳游戏(加入房间) ==========\n\n"; string ip; cout << "请输入对方 IP:"; cin >> ip; sockaddr_in addr; addr.sin_family = AF_INET; addr.sin_port = htons(8888); addr.sin_addr.s_addr = inet_addr(ip.c_str()); if (connect(sock, (sockaddr*)&addr, sizeof(addr)) == SOCKET_ERROR) { cout << "连接失败,检查 IP 和防火墙\n"; closesocket(sock); WSACleanup(); _getch(); return; } int a = 2, b = 2, c = 0, d = 0; string s[] = {"", "石头", "剪刀", "布", "防御", "逃跑"}; while (a > 0 && b > 0) { int x; recv(sock, (char*)&x, sizeof(x), 0); system("cls"); cout << "========== 猜拳游戏 - 对方视角 ==========\n\n"; cout << "对方生命值:" << b << " 你的生命值:" << a << "\n"; cout << "对方能量:" << d << " 你的能量:" << c << "\n\n"; cout << "对方出了:" << s[x] << "\n\n"; int op = 1; if (d == 0) { cout << "能量不足,自动出石头\n"; Sleep(1000); op = 1; } else { cout << "1.石头 2.剪刀 3.布 4.防御 5.逃跑\n"; do cin >> op; while (op < 1 || op > 5); } send(sock, (char*)&op, sizeof(op), 0); int pa = a, pb = b; if (x == 1) { if (op == 1) c++, d++; else if (op == 2) a--, c++, d--; else if (op == 3) c++, d--; else if (op == 4) c++, d--; else if (op == 5) b--, c++, d--; } else if (x == 2) { if (op == 1) b--, c--, d++; else if (op == 2) a--, b--, c--, d--; else if (op == 3) a--, c--, d--; else if (op == 4) c--, d--; else if (op == 5) b = 0; } else if (x == 3) { if (op == 1) c--, d++; else if (op == 2) b--, c--, d--; else if (op == 3) c--, d--; else if (op == 4) c--, d--; else if (op == 5) a--, c--, d--; } else if (x == 4) { if (op == 1) c--, d++; else if (op == 2) c--, d--; else if (op == 3) c--, d--; else if (op == 4) c--, d--; else if (op == 5) b--, c--, d--; } else if (x == 5) { if (op == 1) a--, c--, d++; else if (op == 2) a = 0; else if (op == 3) b--, c--, d--; else if (op == 4) a--, c--, d--; else if (op == 5) a--, b--, c--, d--; } log("加入 - 玩家2: " + s[op] + ", 玩家1: " + s[x] + ", 玩家2生命: " + to_string(pb) + "->" + to_string(b) + ", 玩家1生命: " + to_string(pa) + "->" + to_string(a)); cout << "\n你出:" << s[op] << " 对方出:" << s[x] << "\n\n"; cout << "你的生命值:" << b << " 对方生命值:" << a; Sleep(3000); } system("cls"); if (a <= 0 && b <= 0) cout << "平局!\n"; else if (b <= 0) cout << "你输了!\n"; else cout << "你赢了!\n"; Sleep(2000); closesocket(sock); WSACleanup();}
void f1yck(){ cout << "欢迎来到隐藏款普通版!"; Sleep(3000); system("cls");750 行未改动全部展开 cout << "请选择: "; int ch = ri(1, 3); if (ch == 3) { logfile.close(); cout << "感谢游玩!\n"; cout << "\n感谢游玩!\n"; break; } else if (ch == 2) va(); else if (ch == 1) {68 行未改动 Sleep(100); cout << "5.连续击败7人成为最终胜利者。\n"; Sleep(100); cout << "6.打败过其他所有人后获得弑神称号,可在任意一次对局选择是否使用,每盘只能用一次。\n\n"; Sleep(1100); cout << "(五)晋级赛\n"; Sleep(100); cout << "1.在普通版基础上变成晋级赛,16人游戏。\n\n"; Sleep(600); cout << "选择版本:"; int n = ri(1, 5); system("cls"); logfile << "\n=== 新游戏开始 (版本 " << n << ") ===\n"; if (n == 1) { cout << "1.规模:正常 2.规模:疯狂\n\n"; cout << "1.正常 2.疯狂 3.双人联机\n\n"; int x; x = ri(1, 5); x = ri(1, 3); if (x == 1) { if (rand() % 100 == 0) f1yck(); else f1(); } else if (x == 2) f1nrm(); else if (x == 3) { cout << "1.创建服务器 2.加入服务器\n"; int a = ri(1, 2); if (a == 1) f1vs_Create(); else f1vs_Jion(); } } else if (n == 2) f2(); else if (n == 3) f3(); else if (n == 4) f4();6 行未改动 logfile.close(); return 0;}```
### HTML版本```html line-numbers<!DOCTYPE html><html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>拍拍游戏</title><style> * { box-sizing: border-box; margin: 0; padding: 0; } body { font-family: "Microsoft YaHei", sans-serif; background: #1a1a2e; color: #e0e0e0; min-height: 100vh; display: flex; justify-content: center; padding: 20px; } .app { width: 100%; max-width: 900px; background: #16213e; border-radius: 16px; box-shadow: 0 8px 32px rgba(0,0,0,0.5); overflow: hidden; display: flex; flex-direction: column; } .header { background: #0f3460; padding: 16px 24px; font-size: 20px; font-weight: bold; color: #e94560; text-align: center; letter-spacing: 2px; } .screen { padding: 24px; flex: 1; display: flex; flex-direction: column; gap: 16px; } .menu-title { font-size: 22px; text-align: center; margin-bottom: 8px; color: #4ec9b0; } .menu-btn { display: block; width: 100%; padding: 14px; margin: 6px 0; background: #0f3460; color: #e0e0e0; border: 2px solid #1a4a7a; border-radius: 10px; font-size: 16px; cursor: pointer; transition: all 0.2s; text-align: left; } .menu-btn:hover { background: #1a4a7a; border-color: #e94560; transform: translateX(4px); } .menu-btn .desc { display: block; font-size: 12px; color: #8899aa; margin-top: 4px; } .hp-bar { display: flex; align-items: center; gap: 8px; margin: 4px 0; } .hp-bar .name { width: 60px; font-size: 14px; font-weight: bold; } .hp-bar .bar { flex: 1; height: 20px; background: #0a0a1a; border-radius: 10px; overflow: hidden; } .hp-bar .fill { height: 100%; transition: width 0.4s; border-radius: 10px; } .hp-bar .num { width: 40px; text-align: right; font-size: 14px; } .battle-info { background: #0a0a1a; border-radius: 10px; padding: 16px; min-height: 120px; font-size: 14px; line-height: 1.8; } .battle-info .you { color: #4ec9b0; } .battle-info .enemy { color: #e94560; } .battle-info .sys { color: #ffd700; } .skill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; } .skill-btn { padding: 12px; background: #0f3460; color: #e0e0e0; border: 2px solid #1a4a7a; border-radius: 8px; font-size: 14px; cursor: pointer; transition: all 0.15s; } .skill-btn:hover:not(:disabled) { background: #1a4a7a; border-color: #4ec9b0; } .skill-btn:disabled { opacity: 0.35; cursor: not-allowed; } .skill-btn.target { border-color: #ffd700; } .log-box { background: #0a0a1a; border-radius: 8px; padding: 12px; max-height: 160px; overflow-y: auto; font-size: 12px; line-height: 1.6; color: #8899aa; } .log-box .entry { border-bottom: 1px solid #1a1a2e; padding: 3px 0; } .result { text-align: center; font-size: 24px; font-weight: bold; padding: 24px; color: #ffd700; } .back-btn { padding: 10px 20px; background: #333; color: #e0e0e0; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; align-self: flex-start; } .back-btn:hover { background: #555; } .round-display { text-align: center; font-size: 16px; color: #ffd700; padding: 8px; } .arena { display: flex; justify-content: space-around; gap: 8px; flex-wrap: wrap; } .player-card { flex: 1; min-width: 100px; background: #0a0a1a; border-radius: 10px; padding: 10px; text-align: center; border: 2px solid #1a4a7a; transition: all 0.3s; } .player-card.king { border-color: #ffd700; box-shadow: 0 0 15px rgba(255,215,0,0.4); } .player-card.dead { opacity: 0.4; border-color: #333; } .player-card .pname { font-weight: bold; font-size: 14px; margin-bottom: 6px; } .player-card .pbullets { font-size: 12px; color: #4ec9b0; } .player-card .pgod { font-size: 11px; color: #ffd700; margin-top: 4px; } .player-card .php { font-size: 13px; margin-top: 4px; } .badge { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 11px; margin: 2px; } .badge.king { background: #ffd700; color: #000; } .badge.god { background: #e94560; color: #fff; } .action-reveal { display: flex; justify-content: space-around; gap: 12px; background: #0a0a1a; border-radius: 10px; padding: 16px; border: 2px solid #ffd700; animation: flash 0.6s; } @keyframes flash { 0% { border-color: #e94560; } 50% { border-color: #ffd700; } 100% { border-color: #ffd700; } } .action-reveal .side { flex: 1; text-align: center; } .action-reveal .side .label { font-size: 12px; color: #8899aa; margin-bottom: 6px; } .action-reveal .side .skill { font-size: 22px; font-weight: bold; padding: 10px; border-radius: 8px; } .action-reveal .side.you .skill { color: #4ec9b0; background: rgba(78,201,176,0.15); border: 2px solid #4ec9b0; } .action-reveal .side.enemy .skill { color: #e94560; background: rgba(233,69,96,0.15); border: 2px solid #e94560; }</style></head><body><div class="app"> <div class="header">拍 拍 游 戏</div> <div class="screen" id="screen"></div></div>
<script>const screen = document.getElementById('screen');
const state = { mode: null, logs: []};
const STORAGE_KEY = 'paipai_logs_v1';
function loadLogs() { try { const saved = localStorage.getItem(STORAGE_KEY); if (saved) state.logs = JSON.parse(saved); } catch (e) { state.logs = []; }}
function saveLogs() { try { localStorage.setItem(STORAGE_KEY, JSON.stringify(state.logs)); } catch (e) {}}
function clearScreen() { screen.innerHTML = ''; }
function addLog(msg) { state.logs.push(msg); if (state.logs.length > 2000) state.logs.shift(); saveLogs();}
function renderLogBox() { const box = document.createElement('div'); box.className = 'log-box'; const recent = state.logs.slice(-30).reverse(); box.innerHTML = recent.map(l => `<div class="entry">${l}</div>`).join(''); return box;}
function exportLog() { if (state.logs.length === 0) { alert('暂无记录可导出!'); return; } const text = state.logs.join('\n'); const blob = new Blob([text], { type: 'text/plain;charset=utf-8' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = 'game_log.txt'; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); alert('日志已导出为 game_log.txt');}
function showMainMenu() { clearScreen(); const title = document.createElement('div'); title.className = 'menu-title'; title.textContent = '选择版本'; screen.appendChild(title);
const modes = [ { id: 1, name: '普通版', desc: '两人对局,每人2滴血,5种技能' }, { id: 2, name: '牌版', desc: '两人对局,每人3滴血,7种技能' }, { id: 3, name: '提高版', desc: '4人混战,含破甲弹、手雷' }, { id: 4, name: '擂台版', desc: '8人车轮战,含弑神称号' }, { id: 5, name: '晋级赛', desc: '16人淘汰赛,1/16 到决赛' }, { id: 6, name: '疯狂普通版', desc: '每人4滴血,超级技能,返还子弹' }, ];
modes.forEach(m => { const btn = document.createElement('button'); btn.className = 'menu-btn'; btn.innerHTML = `${m.name}<span class="desc">${m.desc}</span>`; btn.onclick = () => startMode(m.id); screen.appendChild(btn); });
const logBtn = document.createElement('button'); logBtn.className = 'menu-btn'; logBtn.innerHTML = `查看记录<span class="desc">查看本局游戏日志</span>`; logBtn.onclick = () => showLogs(); screen.appendChild(logBtn);
const exportBtn = document.createElement('button'); exportBtn.className = 'menu-btn'; exportBtn.innerHTML = `导出日志<span class="desc">下载 game_log.txt 到硬盘</span>`; exportBtn.onclick = () => exportLog(); screen.appendChild(exportBtn);
const clearBtn = document.createElement('button'); clearBtn.className = 'menu-btn'; clearBtn.innerHTML = `清空记录<span class="desc">删除所有日志(包括已保存的)</span>`; clearBtn.onclick = () => { if (confirm('确定要清空所有记录吗?')) { state.logs = []; saveLogs(); addLog('=== 记录已清空 ==='); alert('已清空'); } }; screen.appendChild(clearBtn);}
function showLogs() { clearScreen(); const back = document.createElement('button'); back.className = 'back-btn'; back.textContent = '← 返回'; back.onclick = showMainMenu; screen.appendChild(back);
const title = document.createElement('div'); title.className = 'menu-title'; title.textContent = '游戏记录'; screen.appendChild(title);
if (state.logs.length === 0) { const p = document.createElement('div'); p.textContent = '暂无记录'; p.style.textAlign = 'center'; p.style.color = '#8899aa'; screen.appendChild(p); return; }
const box = document.createElement('div'); box.className = 'log-box'; box.style.maxHeight = '500px'; box.innerHTML = state.logs.map(l => `<div class="entry">${l}</div>`).join(''); screen.appendChild(box);
const exportBtn = document.createElement('button'); exportBtn.className = 'skill-btn'; exportBtn.textContent = '导出为 game_log.txt'; exportBtn.onclick = () => exportLog(); screen.appendChild(exportBtn);}
function startMode(id) { state.mode = id; if (id === 1) { const trigger = Math.floor(Math.random() * 100) === 0; if (trigger) { addLog('=== 【隐藏款普通版】触发! ==='); startF1yck(); } else { addLog('=== 开始普通版 ==='); startF1(); } } else if (id === 2) { addLog('=== 开始牌版 ==='); startF2(); } else if (id === 3) { addLog('=== 开始提高版 ==='); startF3(); } else if (id === 4) { addLog('=== 开始擂台版 ==='); startF4(); } else if (id === 5) { addLog('=== 开始晋级赛 ==='); startF5(); } else if (id === 6) { addLog('=== 开始疯狂普通版 ==='); startF1nrm(); }}
function skillName1(op) { return ['','装子弹','普攻','反弹','防御','自毙'][op]; }function skillName2(op) { return ['','装子弹','防御','反弹','顺子','连对','小王','大王'][op]; }function skillName3(op) { return ['无','装子弹','普攻','反弹','防御','自毙','破甲弹','手雷'][op]; }function skillNameNrm(op) { return ['','装子弹','普攻','反弹','防御','自毙','超级普攻','超级反弹','超级防御','超级自毙'][op]; }
function hpBar(name, hp, maxHp, color) { const pct = Math.max(0, hp) / maxHp * 100; return ` <div class="hp-bar"> <div class="name" style="color:${color}">${name}</div> <div class="bar"><div class="fill" style="width:${pct}%;background:${color}"></div></div> <div class="num">${Math.max(0, hp)}/${maxHp}</div> </div> `;}
function delay(ms) { return new Promise(r => setTimeout(r, ms)); }
function actionReveal(youSkill, enemySkill) { return ` <div class="action-reveal"> <div class="side you"> <div class="label">你出</div> <div class="skill">${youSkill}</div> </div> <div class="side enemy"> <div class="label">对手出</div> <div class="skill">${enemySkill}</div> </div> </div> `;}
async function startF1() { let a = 2, b = 2, c = 0, d = 0; clearScreen();
const back = document.createElement('button'); back.className = 'back-btn'; back.textContent = '← 返回主菜单'; back.onclick = () => { if (confirm('确定要退出当前对局吗?')) showMainMenu(); }; screen.appendChild(back);
const title = document.createElement('div'); title.className = 'menu-title'; title.textContent = '普通版'; screen.appendChild(title);
const hpDiv = document.createElement('div'); screen.appendChild(hpDiv);
const info = document.createElement('div'); info.className = 'battle-info'; screen.appendChild(info);
const skillDiv = document.createElement('div'); skillDiv.className = 'skill-grid'; screen.appendChild(skillDiv);
screen.appendChild(renderLogBox());
function render() { hpDiv.innerHTML = hpBar('你', a, 2, '#4ec9b0') + hpBar('对手', b, 2, '#e94560'); }
function updateLog() { const old = screen.querySelector('.log-box'); if (old) screen.replaceChild(renderLogBox(), old); }
async function playerTurn(op) { skillDiv.innerHTML = ''; info.innerHTML = '<div class="sys">拍拍...</div>'; await delay(400);
let x = 1; if (d > 0) x = Math.floor(Math.random() * 5) + 1;
const prev_a = a, prev_b = b;
if (op === 1) { if (x === 1) { c++; d++; } else if (x === 2) { a--; c++; d--; } else if (x === 3) { c++; d--; } else if (x === 4) { c++; d--; } else if (x === 5) { b--; c++; d--; } } else if (op === 2) { if (x === 1) { b--; c--; d++; } else if (x === 2) { a--; b--; c--; d--; } else if (x === 3) { a--; c--; d--; } else if (x === 4) { c--; d--; } else if (x === 5) { b = 0; } } else if (op === 3) { if (x === 1) { c--; d++; } else if (x === 2) { b--; c--; d--; } else if (x === 3) { c--; d--; } else if (x === 4) { c--; d--; } else if (x === 5) { a--; c--; d--; } } else if (op === 4) { if (x === 1) { c--; d++; } else if (x === 2) { c--; d--; } else if (x === 3) { c--; d--; } else if (x === 4) { c--; d--; } else if (x === 5) { b--; c--; d--; } } else if (op === 5) { if (x === 1) { a--; c--; d++; } else if (x === 2) { a = 0; } else if (x === 3) { b--; c--; d--; } else if (x === 4) { a--; c--; d--; } else if (x === 5) { a--; b--; c--; d--; } }
addLog(`你:${skillName1(op)} | 对手:${skillName1(x)} | 你 ${prev_a}→${a} | 对手 ${prev_b}→${b}`);
info.innerHTML = actionReveal(skillName1(op), skillName1(x)); render(); updateLog(); await delay(1400);
if (a > 0 && b > 0) { showSkillButtons(); } else { finishF1(); } }
function showSkillButtons() { skillDiv.innerHTML = ''; if (c === 0) { const btn = document.createElement('button'); btn.className = 'skill-btn'; btn.textContent = '装子弹(无子弹自动)'; btn.onclick = () => playerTurn(1); skillDiv.appendChild(btn); setTimeout(() => playerTurn(1), 600); } else { const skills = [ { op: 1, name: '装子弹' }, { op: 2, name: '普攻' }, { op: 3, name: '反弹' }, { op: 4, name: '防御' }, { op: 5, name: '自毙' }, ]; skills.forEach(s => { const btn = document.createElement('button'); btn.className = 'skill-btn'; btn.textContent = s.name; btn.onclick = () => playerTurn(s.op); skillDiv.appendChild(btn); }); } }
function finishF1() { skillDiv.innerHTML = ''; let result = ''; if (a === 0 && b === 0) { result = '平局!'; addLog('结果: 平局'); } else if (a === 0) { result = '你输了!'; addLog('结果: 你输了'); } else { result = '你赢了!'; addLog('结果: 你赢了'); }
info.innerHTML = `<div class="result">${result}</div>`;
const retry = document.createElement('button'); retry.className = 'skill-btn'; retry.textContent = '再来一局'; retry.onclick = () => startF1(); skillDiv.appendChild(retry);
const backBtn = document.createElement('button'); backBtn.className = 'skill-btn'; backBtn.textContent = '返回主菜单'; backBtn.onclick = showMainMenu; skillDiv.appendChild(backBtn);
updateLog(); }
render(); showSkillButtons();}
async function startF1nrm() { let a = 4, b = 4, c = 0, d = 0; clearScreen();
const back = document.createElement('button'); back.className = 'back-btn'; back.textContent = '← 返回主菜单'; back.onclick = () => { if (confirm('确定要退出当前对局吗?')) showMainMenu(); }; screen.appendChild(back);
const title = document.createElement('div'); title.className = 'menu-title'; title.textContent = '疯狂普通版'; screen.appendChild(title);
const ruleBox = document.createElement('div'); ruleBox.className = 'battle-info'; ruleBox.innerHTML = ` <div class="sys">========疯狂普通版========</div><br> <div>1.在普通版上增加了超级普攻、超级反弹、超级防御、超级自毙,每人4滴血。</div> <div>2.超级普攻:消耗2颗子弹,造成2滴血的伤害。当未对对方造成伤害时,返回1颗子弹;当被反弹伤害时,返回2颗子弹。</div> <div>3.超级反弹:消耗2颗子弹,反弹所有伤害。当扑空时,返回1颗子弹;当自己造成伤害时,返回2颗子弹。</div> <div>4.超级防御:消耗2颗子弹,抵消所有伤害。</div> <div>5.超级自毙:消耗2颗子弹,造成2滴血伤害。当自己被自己造成伤害时,返回2颗子弹。</div> <div>6.超级普攻可破普通反弹,双方造成1滴血伤害;可破防御,对方造成1滴血伤害。</div> `; screen.appendChild(ruleBox); await delay(3000); ruleBox.remove();
const hpDiv = document.createElement('div'); screen.appendChild(hpDiv);
const info = document.createElement('div'); info.className = 'battle-info'; screen.appendChild(info);
const skillDiv = document.createElement('div'); skillDiv.className = 'skill-grid'; screen.appendChild(skillDiv);
screen.appendChild(renderLogBox());
function render() { hpDiv.innerHTML = hpBar('你', a, 4, '#4ec9b0') + hpBar('对手', b, 4, '#e94560'); }
function updateLog() { const old = screen.querySelector('.log-box'); if (old) screen.replaceChild(renderLogBox(), old); }
function getSkills() { if (c === 0) return [{ op: 1, name: '装子弹' }]; if (c === 1) return [ { op: 1, name: '装子弹' }, { op: 2, name: '普攻' }, { op: 3, name: '反弹' }, { op: 4, name: '防御' }, { op: 5, name: '自毙' }, ]; return [ { op: 1, name: '装子弹' }, { op: 2, name: '普攻' }, { op: 3, name: '反弹' }, { op: 4, name: '防御' }, { op: 5, name: '自毙' }, { op: 6, name: '超级普攻' }, { op: 7, name: '超级反弹' }, { op: 8, name: '超级防御' }, { op: 9, name: '超级自毙' }, ]; }
async function playerTurn(op) { skillDiv.innerHTML = ''; info.innerHTML = '<div class="sys">拍拍...</div>'; await delay(400);
let x = 1; if (d > 0) x = Math.floor(Math.random() * 9) + 1;
const prev_a = a, prev_b = b; const prev_c = c, prev_d = d;
if (op === 1) { c++; if (x === 1) d++; else if (x === 2) { a--; d--; } else if (x === 3) d--; else if (x === 4) d--; else if (x === 5) { b--; d--; } else if (x === 6) { a -= 2; d -= 2; } else if (x === 7) d--; else if (x === 8) d -= 2; else if (x === 9) { b -= 2; d -= 2; } } else if (op === 2) { c--; if (x === 1) { b--; d++; } else if (x === 2) { a--; b--; d--; } else if (x === 3) { a--; d--; } else if (x === 4) d--; else if (x === 5) b = 0; else if (x === 6) { a--; b -= 2; d -= 2; } else if (x === 7) { a--; d--; } else if (x === 8) d -= 2; else if (x === 9) { a--; b -= 2; d -= 2; } } else if (op === 3) { c--; if (x === 1) d++; else if (x === 2) { b--; d--; } else if (x === 3) d--; else if (x === 4) d--; else if (x === 5) { a--; d--; } else if (x === 6) { a--; d -= 2; } else if (x === 7) { b -= 2; d -= 2; } else if (x === 8) d -= 2; else if (x === 9) { a -= 2; d -= 2; } } else if (op === 4) { c--; if (x === 1) d++; else if (x === 2) d--; else if (x === 3) d--; else if (x === 4) d--; else if (x === 5) { b--; d--; } else if (x === 6) d -= 2; else if (x === 7) d--; else if (x === 8) d -= 2; else if (x === 9) { b -= 2; d -= 2; } } else if (op === 5) { c--; if (x === 1) { a--; d++; } else if (x === 2) a = 0; else if (x === 3) { b--; d--; } else if (x === 4) { a--; d--; } else if (x === 5) { a--; b--; d--; } else if (x === 6) { a--; d -= 2; } else if (x === 7) { a--; d--; } else if (x === 8) { a--; d -= 2; } else if (x === 9) a = 0; } else if (op === 6) { c -= 2; if (x === 1) { b -= 2; d++; } else if (x === 2) { a--; b -= 2; d--; } else if (x === 3) { a--; b--; d--; } else if (x === 4) { b--; d--; } else if (x === 5) { b -= 3; d--; } else if (x === 6) { a -= 2; b -= 2; d -= 2; } else if (x === 7) { a -= 2; c += 2; d -= 2; } else if (x === 8) { c += 1; d -= 2; } else if (x === 9) { b -= 4; d -= 2; } } else if (op === 7) { c -= 2; if (x === 1) { c++; d++; } else if (x === 2) { b--; c += 2; d--; } else if (x === 3) { c++; d--; } else if (x === 4) { c++; d--; } else if (x === 5) { b--; c += 2; d--; } else if (x === 6) { a--; c += 2; d -= 2; } else if (x === 7) { c++; d -= 2; } else if (x === 8) { c++; d -= 2; } else if (x === 9) { b -= 2; c += 2; d -= 2; } } else if (op === 8) { c -= 2; if (x === 1) { c++; d++; } else if (x === 2) { c++; d--; } else if (x === 3) { c++; d--; } else if (x === 4) { c++; d--; } else if (x === 5) { c++; d--; } else if (x === 6) { c++; d -= 2; } else if (x === 7) { c++; d--; } else if (x === 8) { c++; d -= 2; } else if (x === 9) { c++; d -= 2; } } else if (op === 9) { c -= 2; a -= 2; if (x === 1) d++; else if (x === 2) a = 0; else if (x === 3) d--; else if (x === 4) d--; else if (x === 5) { b--; d--; } else if (x === 6) d -= 2; else if (x === 7) d--; else if (x === 8) d -= 2; else if (x === 9) { c += 2; d -= 2; } }
addLog(`你:${skillNameNrm(op)} | 对手:${skillNameNrm(x)} | 你 HP ${prev_a}→${a} | 对手 HP ${prev_b}→${b} | 子弹 ${prev_c}→${c} / ${prev_d}→${d}`);
info.innerHTML = actionReveal(skillNameNrm(op), skillNameNrm(x)); render(); updateLog(); await delay(1400);
if (a > 0 && b > 0) { showSkillButtons(); } else { finishF1nrm(); } }
function showSkillButtons() { skillDiv.innerHTML = ''; getSkills().forEach(s => { const btn = document.createElement('button'); btn.className = 'skill-btn'; btn.textContent = s.name; btn.onclick = () => playerTurn(s.op); skillDiv.appendChild(btn); }); }
function finishF1nrm() { skillDiv.innerHTML = ''; let result = ''; if (a <= 0) { result = '你输了!'; addLog('结果: 你输了'); } else { result = '你赢了!'; addLog('结果: 你赢了'); }
info.innerHTML = `<div class="result">${result}</div>`;
const retry = document.createElement('button'); retry.className = 'skill-btn'; retry.textContent = '再来一局'; retry.onclick = () => startF1nrm(); skillDiv.appendChild(retry);
const backBtn = document.createElement('button'); backBtn.className = 'skill-btn'; backBtn.textContent = '返回主菜单'; backBtn.onclick = showMainMenu; skillDiv.appendChild(backBtn);
updateLog(); }
render(); showSkillButtons();}
async function startF1yck() { let a = 2, b = 2, c = 0, d = 0; clearScreen();
const back = document.createElement('button'); back.className = 'back-btn'; back.textContent = '← 返回主菜单'; back.onclick = () => { if (confirm('确定要退出当前对局吗?')) showMainMenu(); }; screen.appendChild(back);
const title = document.createElement('div'); title.className = 'menu-title'; title.textContent = '隐藏款普通版'; title.style.color = '#ff0000'; screen.appendChild(title);
const welcome = document.createElement('div'); welcome.className = 'battle-info'; welcome.innerHTML = '<div class="sys">欢迎来到隐藏款普通版!<br>【警告】对手似乎看穿了你的所有意图……</div>'; screen.appendChild(welcome); await delay(2500);
const hpDiv = document.createElement('div'); screen.appendChild(hpDiv);
const info = document.createElement('div'); info.className = 'battle-info'; screen.appendChild(info);
const skillDiv = document.createElement('div'); skillDiv.className = 'skill-grid'; screen.appendChild(skillDiv);
screen.appendChild(renderLogBox());
function render() { hpDiv.innerHTML = hpBar('你', a, 2, '#4ec9b0') + hpBar('对手', b, 2, '#e94560'); }
function updateLog() { const old = screen.querySelector('.log-box'); if (old) screen.replaceChild(renderLogBox(), old); }
async function playerTurn(op) { skillDiv.innerHTML = ''; info.innerHTML = '<div class="sys">拍拍...</div>'; await delay(400);
let x = 1; if (d > 0) { if (op === 1) x = 2; if (op === 2) x = 3; if (op === 3) x = 5; if (op === 5) x = 2; }
const prev_a = a, prev_b = b;
if (op === 1) { if (x === 1) { c++; d++; } else if (x === 2) { a--; c++; d--; } else if (x === 3) { c++; d--; } else if (x === 4) { c++; d--; } else if (x === 5) { b--; c++; d--; } } else if (op === 2) { if (x === 1) { b--; c--; d++; } else if (x === 2) { a--; b--; c--; d--; } else if (x === 3) { a--; c--; d--; } else if (x === 4) { c--; d--; } else if (x === 5) { b = 0; } } else if (op === 3) { if (x === 1) { c--; d++; } else if (x === 2) { b--; c--; d--; } else if (x === 3) { c--; d--; } else if (x === 4) { c--; d--; } else if (x === 5) { a--; c--; d--; } } else if (op === 4) { if (x === 1) { c--; d++; } else if (x === 2) { c--; d--; } else if (x === 3) { c--; d--; } else if (x === 4) { c--; d--; } else if (x === 5) { b--; c--; d--; } } else if (op === 5) { if (x === 1) { a--; c--; d++; } else if (x === 2) { a = 0; } else if (x === 3) { b--; c--; d--; } else if (x === 4) { a--; c--; d--; } else if (x === 5) { a--; b--; c--; d--; } }
addLog(`[隐藏] 你:${skillName1(op)} | 对手:${skillName1(x)} | 你 ${prev_a}→${a} | 对手 ${prev_b}→${b}`);
info.innerHTML = actionReveal(skillName1(op), skillName1(x)); render(); updateLog(); await delay(1400);
if (a > 0 && b > 0) { showSkillButtons(); } else { finishF1yck(); } }
function showSkillButtons() { skillDiv.innerHTML = ''; if (c === 0) { const btn = document.createElement('button'); btn.className = 'skill-btn'; btn.textContent = '装子弹(无子弹自动)'; btn.onclick = () => playerTurn(1); skillDiv.appendChild(btn); setTimeout(() => playerTurn(1), 600); } else { const skills = [ { op: 1, name: '装子弹' }, { op: 2, name: '普攻' }, { op: 3, name: '反弹' }, { op: 4, name: '防御' }, { op: 5, name: '自毙' }, ]; skills.forEach(s => { const btn = document.createElement('button'); btn.className = 'skill-btn'; btn.textContent = s.name; btn.onclick = () => playerTurn(s.op); skillDiv.appendChild(btn); }); } }
function finishF1yck() { skillDiv.innerHTML = ''; let result = ''; if (a === 0 && b === 0) { result = '平局!'; addLog('[隐藏] 结果: 平局'); } else if (a === 0) { result = '你输了!'; addLog('[隐藏] 结果: 你输了'); } else { result = '你赢了!'; addLog('[隐藏] 结果: 你赢了'); }
info.innerHTML = `<div class="result">${result}</div>`;
const retry = document.createElement('button'); retry.className = 'skill-btn'; retry.textContent = '再来一局'; retry.onclick = () => startF1yck(); skillDiv.appendChild(retry);
const backBtn = document.createElement('button'); backBtn.className = 'skill-btn'; backBtn.textContent = '返回主菜单'; backBtn.onclick = showMainMenu; skillDiv.appendChild(backBtn);
updateLog(); }
render(); showSkillButtons();}
async function startF2() { let a = 3, b = 3, c = 0, d = 0; clearScreen();
const back = document.createElement('button'); back.className = 'back-btn'; back.textContent = '← 返回主菜单'; back.onclick = () => { if (confirm('确定要退出当前对局吗?')) showMainMenu(); }; screen.appendChild(back);
const title = document.createElement('div'); title.className = 'menu-title'; title.textContent = '牌版'; screen.appendChild(title);
const hpDiv = document.createElement('div'); screen.appendChild(hpDiv);
const info = document.createElement('div'); info.className = 'battle-info'; screen.appendChild(info);
const skillDiv = document.createElement('div'); skillDiv.className = 'skill-grid'; screen.appendChild(skillDiv);
screen.appendChild(renderLogBox());
function render() { hpDiv.innerHTML = hpBar('你', a, 3, '#4ec9b0') + hpBar('对手', b, 3, '#e94560'); }
function updateLog() { const old = screen.querySelector('.log-box'); if (old) screen.replaceChild(renderLogBox(), old); }
function getSkills() { if (c === 0) return [{op:1,name:'装子弹'},{op:2,name:'防御'}]; if (c === 1) return [{op:1,name:'装子弹'},{op:2,name:'防御'},{op:3,name:'反弹'},{op:4,name:'顺子'}]; if (c === 2) return [{op:1,name:'装子弹'},{op:2,name:'防御'},{op:3,name:'反弹'},{op:4,name:'顺子'},{op:5,name:'连对'}]; if (c === 3) return [{op:1,name:'装子弹'},{op:2,name:'防御'},{op:3,name:'反弹'},{op:4,name:'顺子'},{op:5,name:'连对'},{op:6,name:'小王'}]; return [{op:1,name:'装子弹'},{op:2,name:'防御'},{op:3,name:'反弹'},{op:4,name:'顺子'},{op:5,name:'连对'},{op:6,name:'小王'},{op:7,name:'大王'}]; }
async function playerTurn(op) { skillDiv.innerHTML = ''; info.innerHTML = '<div class="sys">拍拍...</div>'; await delay(400);
let x; if (d <= 0) x = Math.floor(Math.random() * 2) + 1; else if (d === 1) x = Math.floor(Math.random() * 4) + 1; else if (d === 2) x = Math.floor(Math.random() * 5) + 1; else if (d === 3) x = Math.floor(Math.random() * 6) + 1; else x = Math.floor(Math.random() * 7) + 1;
const prev_a = a, prev_b = b;
if (op === 1) { if (x === 1) { c++; d++; } else if (x === 2) { c++; d--; } else if (x === 3) { c++; d--; } else if (x === 4) { a--; c++; d--; } else if (x === 5) { a -= 2; c++; d -= 2; } else if (x === 6) { a = 0; } else if (x === 7) { a = 0; } } else if (op === 2) { if (x === 1) { d++; } else if (x === 2) {} else if (x === 3) { d--; } else if (x === 4) { d--; } else if (x === 5) { a--; d -= 2; } else if (x === 6) { a -= 2; d -= 3; } else if (x === 7) { a = 0; } } else if (op === 3) { if (x === 1) { c--; d++; } else if (x === 2) { c--; } else if (x === 3) { c--; d--; } else if (x === 4) { b--; c--; d--; } else if (x === 5) { b -= 2; c--; d -= 2; } else if (x === 6) { b = 0; } else if (x === 7) { b = 0; } } else if (op === 4) { if (x === 1) { b--; c--; d++; } else if (x === 2) { c--; } else if (x === 3) { a--; c--; d--; } else if (x === 4) { c--; d--; } else if (x === 5) { a--; c--; d -= 2; } else if (x === 6) { a -= 2; a--; c -= 3; } else if (x === 7) { a = 0; } } else if (op === 5) { if (x === 1) { b -= 2; c -= 2; d++; } else if (x === 2) { b--; c -= 2; } else if (x === 3) { a -= 2; c -= 2; d--; } else if (x === 4) { b--; c -= 2; d--; } else if (x === 5) { c -= 2; d -= 2; } else if (x === 6) { a--; c -= 2; d -= 3; } else if (x === 7) { a -= 2; c -= 2; d -= 4; } } else if (op === 6) { if (x === 1) { b = 0; } else if (x === 2) { b -= 2; c -= 3; } else if (x === 3) { a = 0; } else if (x === 4) { b -= 2; c -= 3; d--; } else if (x === 5) { b--; c -= 3; d -= 2; } else if (x === 6) { c -= 3; d -= 3; } else if (x === 7) { a--; c -= 3; d -= 4; } } else if (op === 7) { if (x === 1) { b = 0; } else if (x === 2) { b = 0; } else if (x === 3) { a = 0; } else if (x === 4) { b = 0; } else if (x === 5) { b -= 2; c -= 4; d -= 2; } else if (x === 6) { b--; c -= 4; d -= 3; } else if (x === 7) { c -= 4; d -= 4; } }
addLog(`你:${skillName2(op)} | 对手:${skillName2(x)} | 你 ${prev_a}→${a} | 对手 ${prev_b}→${b}`);
info.innerHTML = actionReveal(skillName2(op), skillName2(x)); render(); updateLog(); await delay(1400);
if (a > 0 && b > 0) showSkillButtons(); else finishF2(); }
function showSkillButtons() { skillDiv.innerHTML = ''; getSkills().forEach(s => { const btn = document.createElement('button'); btn.className = 'skill-btn'; btn.textContent = s.name; btn.onclick = () => playerTurn(s.op); skillDiv.appendChild(btn); }); }
function finishF2() { skillDiv.innerHTML = ''; let result = a <= 0 ? '你输了!' : '你赢了!'; addLog(`结果: ${result}`); info.innerHTML = `<div class="result">${result}</div>`;
const retry = document.createElement('button'); retry.className = 'skill-btn'; retry.textContent = '再来一局'; retry.onclick = () => startF2(); skillDiv.appendChild(retry);
const backBtn = document.createElement('button'); backBtn.className = 'skill-btn'; backBtn.textContent = '返回主菜单'; backBtn.onclick = showMainMenu; skillDiv.appendChild(backBtn); updateLog(); }
render(); showSkillButtons();}
async function startF3() { let a = 2, b = 2, c = 2, d = 2, e = 0, f = 0, g = 0, h = 0; let cnt = 4, ct = 0, ad = 0, bd = 0, cd = 0, dd = 0;
clearScreen();
const back = document.createElement('button'); back.className = 'back-btn'; back.textContent = '← 返回主菜单'; back.onclick = () => { if (confirm('确定要退出当前对局吗?')) showMainMenu(); }; screen.appendChild(back);
const title = document.createElement('div'); title.className = 'menu-title'; title.textContent = '提高版(4人混战)'; screen.appendChild(title);
const arena = document.createElement('div'); arena.className = 'arena'; screen.appendChild(arena);
const info = document.createElement('div'); info.className = 'battle-info'; screen.appendChild(info);
const skillDiv = document.createElement('div'); skillDiv.className = 'skill-grid'; screen.appendChild(skillDiv);
screen.appendChild(renderLogBox());
const needTargetOps = [2, 3, 5, 6];
function renderArena() { const names = ['你', '1号', '2号', '3号']; const hps = [a, b, c, d]; const bullets = [e, f, g, h]; arena.innerHTML = names.map((n, idx) => { const dead = hps[idx] <= 0; return ` <div class="player-card ${dead ? 'dead' : ''}"> <div class="pname">${n}</div> <div class="php">❤️ ${Math.max(0, hps[idx])}</div> <div class="pbullets">🔫 ${bullets[idx]}</div> </div> `; }).join(''); }
function updateLog() { const old = screen.querySelector('.log-box'); if (old) screen.replaceChild(renderLogBox(), old); }
function ff3(a, b, c, d, cx) { if (cx === 0 && a === 0) return true; if (cx === 1 && b === 0) return true; if (cx === 2 && c === 0) return true; if (cx === 3 && d === 0) return true; return false; }
function getSkills() { if (e === 0) return [{op:1,name:'装子弹'}]; if (e === 1) return [{op:1,name:'装子弹'},{op:2,name:'普攻'},{op:3,name:'反弹'},{op:4,name:'防御'},{op:5,name:'自毙'}]; if (e === 2) return [{op:1,name:'装子弹'},{op:2,name:'普攻'},{op:3,name:'反弹'},{op:4,name:'防御'},{op:5,name:'自毙'},{op:6,name:'破甲弹'}]; return [{op:1,name:'装子弹'},{op:2,name:'普攻'},{op:3,name:'反弹'},{op:4,name:'防御'},{op:5,name:'自毙'},{op:6,name:'破甲弹'},{op:7,name:'手雷'}]; }
function needTarget(op) { return needTargetOps.includes(op); }
function render() { renderArena(); }
function showSkillButtons() { skillDiv.innerHTML = ''; if (a <= 0) { doTurn(0, 0); return; } const skills = getSkills(); skills.forEach(s => { const btn = document.createElement('button'); btn.className = 'skill-btn'; btn.textContent = s.name; btn.onclick = () => { if (needTarget(s.op)) chooseTarget(s.op); else doTurn(s.op, 0); }; skillDiv.appendChild(btn); }); }
function chooseTarget(op) { skillDiv.innerHTML = ''; const hint = document.createElement('div'); hint.style.gridColumn = '1 / -1'; hint.style.color = '#ffd700'; hint.textContent = '选择目标:'; skillDiv.appendChild(hint);
const names = ['1号', '2号', '3号']; const hpArr = [b, c, d]; names.forEach((n, idx) => { const targetNum = idx + 1; const btn = document.createElement('button'); btn.className = 'skill-btn target'; btn.textContent = n; btn.disabled = hpArr[idx] <= 0; btn.onclick = () => doTurn(op, targetNum); skillDiv.appendChild(btn); });
const cancel = document.createElement('button'); cancel.className = 'skill-btn'; cancel.textContent = '取消'; cancel.onclick = showSkillButtons; skillDiv.appendChild(cancel); }
async function doTurn(op, n) { skillDiv.innerHTML = ''; info.innerHTML = '<div class="sys">拍拍...</div>'; await delay(400);
let xa = 0, xb = 0, xc = 0, ca = 0, cb = 0, cc = 0;
if (b <= 0) { xa = 0; ca = 0; } else { if (f <= 0) xa = 1; else if (f === 1) xa = Math.floor(Math.random() * 5) + 1; else if (f === 2) xa = Math.floor(Math.random() * 6) + 1; else xa = Math.floor(Math.random() * 7) + 1; if (xa === 2 || xa === 3 || xa === 5 || xa === 6) { do { ca = Math.floor(Math.random() * 3) + 1; } while (ff3(a, b, c, d, ca)); if (ca === 1) ca = 0; } else { ca = 0; } }
if (c <= 0) { xb = 0; cb = 0; } else { if (g <= 0) xb = 1; else if (g === 1) xb = Math.floor(Math.random() * 5) + 1; else if (g === 2) xb = Math.floor(Math.random() * 6) + 1; else xb = Math.floor(Math.random() * 7) + 1; if (xb === 2 || xb === 3 || xb === 5 || xb === 6) { do { cb = Math.floor(Math.random() * 3) + 1; } while (ff3(a, b, c, d, cb)); if (cb === 2) cb = 0; } else { cb = 0; } }
if (d <= 0) { xc = 0; cc = 0; } else { if (h <= 0) xc = 1; else if (h === 1) xc = Math.floor(Math.random() * 5) + 1; else if (h === 2) xc = Math.floor(Math.random() * 6) + 1; else xc = Math.floor(Math.random() * 7) + 1; if (xc === 2 || xc === 3 || xc === 5 || xc === 6) { do { cc = Math.floor(Math.random() * 3) + 1; } while (ff3(a, b, c, d, cc)); if (cc === 3) cc = 0; } else { cc = 0; } }
const hp = [a, b, c, d]; const bult = [e, f, g, h]; const acn = [op, xa, xb, xc]; const tgt = [n, ca, cb, cc]; const def = [0, 0, 0, 0];
for (let i = 0; i < 4; i++) if (acn[i] === 1) bult[i]++; for (let i = 0; i < 4; i++) if (acn[i] === 4 && bult[i] > 0) { bult[i]--; def[i] = 1; } for (let i = 0; i < 4; i++) { if (acn[i] === 5 && bult[i] > 0) { bult[i]--; let rbd = false; for (let j = 0; j < 4; j++) { if (i !== j && hp[j] > 0 && acn[j] === 3 && tgt[j] === i && tgt[i] === j && bult[j] > 0) { bult[j]--; hp[j]--; rbd = true; break; } } if (!rbd) hp[i]--; } } for (let i = 0; i < 4; i++) { for (let j = 0; j < 4; j++) { if (i === j) continue; if (tgt[i] !== j) continue; if (acn[i] === 6 && bult[i] >= 2) { bult[i] -= 2; if (acn[j] === 3 && bult[j] > 0 && tgt[j] === i && hp[j] > 0) { bult[j]--; hp[i]--; } else hp[j]--; } } } for (let i = 0; i < 4; i++) { for (let j = 0; j < 4; j++) { if (i === j) continue; if (tgt[i] !== j) continue; if (acn[i] === 2 && bult[i] > 0) { bult[i]--; if (acn[j] === 3 && bult[j] > 0 && tgt[j] === i && hp[j] > 0) { bult[j]--; hp[i]--; } else if (def[j]) def[j] = 0; else hp[j]--; } } } for (let i = 0; i < 4; i++) if (acn[i] === 3 && bult[i] > 0) bult[i]--; for (let i = 0; i < 4; i++) { if (acn[i] === 7 && bult[i] >= 3) { bult[i] -= 3; for (let j = 0; j < 4; j++) { if (i !== j && hp[j] > 0) { if (def[j]) def[j] = 0; else hp[j]--; } } } }
const old_a = a, old_b = b, old_c = c, old_d = d;
a = hp[0]; e = bult[0]; b = hp[1]; f = bult[1]; c = hp[2]; g = bult[2]; d = hp[3]; h = bult[3];
const names = ['你', '1号', '2号', '3号']; const ops = [op, xa, xb, xc]; const tgts = [n, ca, cb, cc];
function targetText(i) { if (!needTargetOps.includes(ops[i])) return ''; const t = tgts[i]; const tn = (t === 0) ? '你' : names[t]; return ` → ${tn}`; }
let lines = []; for (let i = 0; i < 4; i++) { lines.push(`${names[i]}: ${skillName3(ops[i])}${targetText(i)}`); } lines.push(`血量 你 ${old_a}→${Math.max(0,a)} | 1号 ${old_b}→${Math.max(0,b)} | 2号 ${old_c}→${Math.max(0,c)} | 3号 ${old_d}→${Math.max(0,d)}`); addLog(lines.join(' | '));
let revealHTML = '<div class="action-reveal" style="flex-wrap:wrap">'; for (let i = 0; i < 4; i++) { const skillText = skillName3(ops[i]) + targetText(i); const cls = i === 0 ? 'you' : 'enemy'; revealHTML += ` <div class="side ${cls}" style="min-width:120px"> <div class="label">${names[i]}出</div> <div class="skill" style="font-size:15px">${skillText}</div> </div> `; } revealHTML += '</div>'; revealHTML += `<div style="margin-top:12px">血量:你 ${Math.max(0,a)} | 1号 ${Math.max(0,b)} | 2号 ${Math.max(0,c)} | 3号 ${Math.max(0,d)}</div>`; info.innerHTML = revealHTML;
cnt = 0; if (a > 0) cnt++; else { if (ad === 0) ad = ct; a = 0; } if (b > 0) cnt++; else { if (bd === 0) bd = ct; b = 0; } if (c > 0) cnt++; else { if (cd === 0) cd = ct; c = 0; } if (d > 0) cnt++; else { if (dd === 0) dd = ct; d = 0; }
ct++; render(); updateLog(); await delay(1800);
if (cnt > 1) showSkillButtons(); else finishF3(); }
function finishF3() { skillDiv.innerHTML = ''; let result = ''; if (cnt === 1) { if (a > 0) result = '你赢了!'; else if (b > 0) result = '1号赢了!'; else if (c > 0) result = '2号赢了!'; else if (d > 0) result = '3号赢了!'; } else result = '平局!'; addLog(`结果: ${result}`); info.innerHTML = `<div class="result">${result}</div>`;
const retry = document.createElement('button'); retry.className = 'skill-btn'; retry.textContent = '再来一局'; retry.onclick = () => startF3(); skillDiv.appendChild(retry);
const backBtn = document.createElement('button'); backBtn.className = 'skill-btn'; backBtn.textContent = '返回主菜单'; backBtn.onclick = showMainMenu; skillDiv.appendChild(backBtn); updateLog(); }
render(); showSkillButtons();}
async function startF4() { const names = ['', 'A', 'B', 'C', 'D', 'E', 'F', 'G', '你']; let r = Math.floor(Math.random() * 8) + 1; let i = (r === 8) ? 1 : r + 1; if (i === r) { i = (i === 8) ? 1 : i + 1; }
const records = {}; for (let k = 1; k <= 8; k++) records[k] = [];
let streak = 0, streakOwner = 0; let godOwner = 0, godUsed = false;
clearScreen();
const back = document.createElement('button'); back.className = 'back-btn'; back.textContent = '← 返回主菜单'; back.onclick = () => { if (confirm('确定要退出当前对局吗?')) showMainMenu(); }; screen.appendChild(back);
const title = document.createElement('div'); title.className = 'menu-title'; title.textContent = '擂台版'; screen.appendChild(title);
const arena = document.createElement('div'); arena.className = 'arena'; screen.appendChild(arena);
const roundInfo = document.createElement('div'); roundInfo.className = 'round-display'; screen.appendChild(roundInfo);
const info = document.createElement('div'); info.className = 'battle-info'; screen.appendChild(info);
const skillDiv = document.createElement('div'); skillDiv.className = 'skill-grid'; screen.appendChild(skillDiv);
screen.appendChild(renderLogBox());
function renderArena() { arena.innerHTML = names.slice(1).map((n, idx) => { const num = idx + 1; const isKing = num === r; const isGod = num === godOwner; const beaten = records[num].length; return ` <div class="player-card ${isKing ? 'king' : ''}"> <div class="pname">${n}</div> ${isKing ? '<span class="badge king">擂主</span>' : ''} ${isGod ? '<span class="badge god">弑神</span>' : ''} <div class="pbullets">已胜 ${beaten}/7</div> </div> `; }).join(''); }
function updateLog() { const old = screen.querySelector('.log-box'); if (old) screen.replaceChild(renderLogBox(), old); }
function render() { renderArena(); roundInfo.textContent = `擂主:${names[r]} | 挑战者:${names[i]} | 连续守擂:${streak}`; }
function addRecord(winner, loser) { if (!records[winner].includes(loser)) records[winner].push(loser); }
function hasBeatenAll(num) { return records[num].length >= 7; }
async function playF1Match() { return new Promise(resolve => { let a = 2, b = 2, c = 0, d = 0;
function renderMini() { info.innerHTML = ` ${hpBar('你', a, 2, '#4ec9b0')} ${hpBar('对手', b, 2, '#e94560')} <div>子弹:你 ${c} | 对手 ${d}</div> `; }
function showSkills() { skillDiv.innerHTML = ''; if (c === 0) { const btn = document.createElement('button'); btn.className = 'skill-btn'; btn.textContent = '装子弹'; btn.onclick = () => turn(1); skillDiv.appendChild(btn); } else { [{op:1,n:'装子弹'},{op:2,n:'普攻'},{op:3,n:'反弹'},{op:4,n:'防御'},{op:5,n:'自毙'}].forEach(s => { const btn = document.createElement('button'); btn.className = 'skill-btn'; btn.textContent = s.n; btn.onclick = () => turn(s.op); skillDiv.appendChild(btn); }); } }
async function turn(op) { skillDiv.innerHTML = ''; info.innerHTML = '<div class="sys">拍拍...</div>'; await delay(300);
let x = 1; if (d > 0) x = Math.floor(Math.random() * 5) + 1;
if (op === 1) { if (x === 1) { c++; d++; } else if (x === 2) { a--; c++; d--; } else if (x === 3) { c++; d--; } else if (x === 4) { c++; d--; } else if (x === 5) { b--; c++; d--; } } else if (op === 2) { if (x === 1) { b--; c--; d++; } else if (x === 2) { a--; b--; c--; d--; } else if (x === 3) { a--; c--; d--; } else if (x === 4) { c--; d--; } else if (x === 5) { b = 0; } } else if (op === 3) { if (x === 1) { c--; d++; } else if (x === 2) { b--; c--; d--; } else if (x === 3) { c--; d--; } else if (x === 4) { c--; d--; } else if (x === 5) { a--; c--; d--; } } else if (op === 4) { if (x === 1) { c--; d++; } else if (x === 2) { c--; d--; } else if (x === 3) { c--; d--; } else if (x === 4) { c--; d--; } else if (x === 5) { b--; c--; d--; } } else if (op === 5) { if (x === 1) { a--; c--; d++; } else if (x === 2) { a = 0; } else if (x === 3) { b--; c--; d--; } else if (x === 4) { a--; c--; d--; } else if (x === 5) { a--; b--; c--; d--; } }
info.innerHTML = actionReveal(skillName1(op), skillName1(x)); await delay(1200);
if (a <= 0 || b <= 0) { skillDiv.innerHTML = ''; let res; if (a === 0 && b === 0) res = 1; else if (a === 0) res = 0; else res = 2; resolve(res); } else { showSkills(); } }
renderMini(); showSkills(); }); }
async function runRound() { render(); await delay(800);
let challengerWin = false; let godUsedThisRound = false;
if (godOwner === r && !godUsed && godOwner !== 0) { info.innerHTML = `<div class="sys">擂主 ${names[r]} 拥有弑神称号!</div>`; skillDiv.innerHTML = ''; const useBtn = document.createElement('button'); useBtn.className = 'skill-btn'; useBtn.textContent = '使用弑神(直接获胜)'; useBtn.onclick = () => { godUsedThisRound = true; godUsed = true; challengerWin = false; addLog(`${names[r]} 使用了弑神称号`); info.innerHTML = `<div class="sys">我是弑神,你直接给我掉吧!</div>`; window._resolveGod(); }; skillDiv.appendChild(useBtn);
const skipBtn = document.createElement('button'); skipBtn.className = 'skill-btn'; skipBtn.textContent = '不使用(正常对战)'; skipBtn.onclick = () => { window._resolveSkip(); }; skillDiv.appendChild(skipBtn);
await new Promise(res => { window._resolveGod = res; window._resolveSkip = res; }); await delay(800);
if (godUsedThisRound) { finishRound(false, true); return; } }
if (!godUsedThisRound && godOwner === i && !godUsed && godOwner !== 0) { info.innerHTML = `<div class="sys">挑战者 ${names[i]} 拥有弑神称号!</div>`; skillDiv.innerHTML = ''; const useBtn = document.createElement('button'); useBtn.className = 'skill-btn'; useBtn.textContent = '使用弑神(直接获胜)'; useBtn.onclick = () => { godUsedThisRound = true; godUsed = true; challengerWin = true; addLog(`${names[i]} 使用了弑神称号`); info.innerHTML = `<div class="sys">我是弑神,你直接给我掉吧!</div>`; window._resolveGod2(); }; skillDiv.appendChild(useBtn);
const skipBtn = document.createElement('button'); skipBtn.className = 'skill-btn'; skipBtn.textContent = '不使用(正常对战)'; skipBtn.onclick = () => { window._resolveSkip2(); }; skillDiv.appendChild(skipBtn);
await new Promise(res => { window._resolveGod2 = res; window._resolveSkip2 = res; }); await delay(800);
if (godUsedThisRound) { finishRound(true, true); return; } }
if (r === 8 || i === 8) { info.innerHTML = `<div class="sys">你${r === 8 ? '是擂主' : '是挑战者'},开始对战!</div>`; await delay(800); let res; do { res = await playF1Match(); if (res === 1) { info.innerHTML = `<div class="sys">平局!重新对战……</div>`; addLog('平局,重新对战'); await delay(1500); } } while (res === 1); if (r === 8) challengerWin = (res !== 2); else challengerWin = (res === 2); } else { info.innerHTML = `<div class="sys">AI 对战中...</div>`; await delay(800); challengerWin = Math.random() < 0.5; }
finishRound(challengerWin, false); }
function finishRound(challengerWin, usedGod) { if (challengerWin) { addRecord(i, r); addLog(`${names[i]} 战胜了 ${names[r]},成为新擂主`); r = i; } else { addRecord(r, i); addLog(`${names[r]} 守擂成功`); }
if (streakOwner !== r) { streakOwner = r; streak = 0; } streak++;
if (streak >= 7) { info.innerHTML = `<div class="result">${names[r]} 是最终的胜利者!</div>`; addLog(`最终胜利者: ${names[r]}`); skillDiv.innerHTML = ''; const retry = document.createElement('button'); retry.className = 'skill-btn'; retry.textContent = '再来一局'; retry.onclick = () => startF4(); skillDiv.appendChild(retry); const backBtn = document.createElement('button'); backBtn.className = 'skill-btn'; backBtn.textContent = '返回主菜单'; backBtn.onclick = showMainMenu; skillDiv.appendChild(backBtn); updateLog(); return; }
if (hasBeatenAll(r) && godOwner === 0) { godOwner = r; addLog(`${names[r]} 获得了弑神称号!`); info.innerHTML = `<div class="sys">${names[r]} 获得了弑神称号!</div>`; }
do { i = (i === 8) ? 1 : i + 1; } while (i === r);
render(); updateLog();
skillDiv.innerHTML = ''; const nextBtn = document.createElement('button'); nextBtn.className = 'skill-btn'; nextBtn.textContent = '下一回合'; nextBtn.onclick = () => runRound(); skillDiv.appendChild(nextBtn); }
render(); skillDiv.innerHTML = ''; const startBtn = document.createElement('button'); startBtn.className = 'skill-btn'; startBtn.textContent = '开始第一回合'; startBtn.onclick = () => runRound(); skillDiv.appendChild(startBtn);}
async function startF5() { const allNames = ['你', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'P'];
clearScreen();
const back = document.createElement('button'); back.className = 'back-btn'; back.textContent = '← 返回主菜单'; back.onclick = () => { if (confirm('确定要退出当前对局吗?')) showMainMenu(); }; screen.appendChild(back);
const title = document.createElement('div'); title.className = 'menu-title'; title.textContent = '晋级赛(16人淘汰赛)'; screen.appendChild(title);
const info = document.createElement('div'); info.className = 'battle-info'; screen.appendChild(info);
const skillDiv = document.createElement('div'); skillDiv.className = 'skill-grid'; screen.appendChild(skillDiv);
screen.appendChild(renderLogBox());
function updateLog() { const old = screen.querySelector('.log-box'); if (old) screen.replaceChild(renderLogBox(), old); }
async function playSingleMatch() { return new Promise(resolve => { let a = 2, b = 2, c = 0, d = 0;
function renderMini() { info.innerHTML = ` ${hpBar('你', a, 2, '#4ec9b0')} ${hpBar('对手', b, 2, '#e94560')} <div>子弹:你 ${c} | 对手 ${d}</div> `; }
function showSkills() { skillDiv.innerHTML = ''; if (c === 0) { const btn = document.createElement('button'); btn.className = 'skill-btn'; btn.textContent = '装子弹'; btn.onclick = () => turn(1); skillDiv.appendChild(btn); } else { [{op:1,n:'装子弹'},{op:2,n:'普攻'},{op:3,n:'反弹'},{op:4,n:'防御'},{op:5,n:'自毙'}].forEach(s => { const btn = document.createElement('button'); btn.className = 'skill-btn'; btn.textContent = s.n; btn.onclick = () => turn(s.op); skillDiv.appendChild(btn); }); } }
async function turn(op) { skillDiv.innerHTML = ''; info.innerHTML = '<div class="sys">拍拍...</div>'; await delay(300);
let x = 1; if (d > 0) x = Math.floor(Math.random() * 5) + 1;
if (op === 1) { if (x === 1) { c++; d++; } else if (x === 2) { a--; c++; d--; } else if (x === 3) { c++; d--; } else if (x === 4) { c++; d--; } else if (x === 5) { b--; c++; d--; } } else if (op === 2) { if (x === 1) { b--; c--; d++; } else if (x === 2) { a--; b--; c--; d--; } else if (x === 3) { a--; c--; d--; } else if (x === 4) { c--; d--; } else if (x === 5) { b = 0; } } else if (op === 3) { if (x === 1) { c--; d++; } else if (x === 2) { b--; c--; d--; } else if (x === 3) { c--; d--; } else if (x === 4) { c--; d--; } else if (x === 5) { a--; c--; d--; } } else if (op === 4) { if (x === 1) { c--; d++; } else if (x === 2) { c--; d--; } else if (x === 3) { c--; d--; } else if (x === 4) { c--; d--; } else if (x === 5) { b--; c--; d--; } } else if (op === 5) { if (x === 1) { a--; c--; d++; } else if (x === 2) { a = 0; } else if (x === 3) { b--; c--; d--; } else if (x === 4) { a--; c--; d--; } else if (x === 5) { a--; b--; c--; d--; } }
info.innerHTML = actionReveal(skillName1(op), skillName1(x)); await delay(1200);
if (a <= 0 || b <= 0) { skillDiv.innerHTML = ''; let res; if (a === 0 && b === 0) res = 1; else if (a === 0) res = 0; else res = 2; resolve(res); } else { showSkills(); } }
renderMini(); showSkills(); }); }
async function playMatch(p1, p2) { if (p1 === '你' || p2 === '你') { const opp = (p1 === '你') ? p2 : p1; info.innerHTML = `<div class="sys">你 与 ${opp} 对战!</div>`; addLog(`你 与 ${opp} 对战`); await delay(1500); const res = await playSingleMatch(); return res === 2 ? '你' : opp; } else { info.innerHTML = `<div class="sys">${p1} 与 ${p2} 对战中...</div>`; addLog(`${p1} 与 ${p2} 对战`); await delay(800); return Math.random() < 0.5 ? p1 : p2; } }
const pool16 = [...allNames]; for (let i = pool16.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [pool16[i], pool16[j]] = [pool16[j], pool16[i]]; } const matches16 = []; for (let i = 0; i < 16; i += 2) matches16.push([pool16[i], pool16[i + 1]]);
info.innerHTML = '<div class="sys">第 1 轮(1/16)晋级赛的比赛组合:</div>'; let lines = ''; matches16.forEach(m => { lines += `${m[0]} - ${m[1]}\n`; }); info.innerHTML += `<pre style="color:#e0e0e0;font-family:inherit;">${lines}</pre>`; addLog('第 1 轮(1/16)对阵:' + matches16.map(m => m[0] + '-' + m[1]).join(',')); await delay(2000);
let s8 = []; for (const m of matches16) { const w = await playMatch(m[0], m[1]); s8.push(w); addLog(`第 1 轮:${m[0]} vs ${m[1]} → ${w} 胜`); }
info.innerHTML = `<div class="sys">晋级名单:</div><div>${s8.join(' ')}</div>`; addLog('晋级名单:' + s8.join(' ')); await delay(2000);
const pool8 = [...s8]; for (let i = pool8.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [pool8[i], pool8[j]] = [pool8[j], pool8[i]]; } const matches8 = []; for (let i = 0; i < 8; i += 2) matches8.push([pool8[i], pool8[i + 1]]);
info.innerHTML = '<div class="sys">第 2 轮(1/8)晋级赛的比赛组合:</div>'; lines = ''; matches8.forEach(m => { lines += `${m[0]} - ${m[1]}\n`; }); info.innerHTML += `<pre style="color:#e0e0e0;font-family:inherit;">${lines}</pre>`; addLog('第 2 轮(1/8)对阵:' + matches8.map(m => m[0] + '-' + m[1]).join(',')); await delay(2000);
let s4 = []; for (const m of matches8) { const w = await playMatch(m[0], m[1]); s4.push(w); addLog(`第 2 轮:${m[0]} vs ${m[1]} → ${w} 胜`); }
info.innerHTML = `<div class="sys">晋级名单:</div><div>${s4.join(' ')}</div>`; addLog('晋级名单:' + s4.join(' ')); await delay(2000);
const pool4 = [...s4]; for (let i = pool4.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [pool4[i], pool4[j]] = [pool4[j], pool4[i]]; } const matches4 = []; for (let i = 0; i < 4; i += 2) matches4.push([pool4[i], pool4[i + 1]]);
info.innerHTML = '<div class="sys">第 3 轮(1/4)晋级赛的比赛组合:</div>'; lines = ''; matches4.forEach(m => { lines += `${m[0]} - ${m[1]}\n`; }); info.innerHTML += `<pre style="color:#e0e0e0;font-family:inherit;">${lines}</pre>`; addLog('第 3 轮(1/4)对阵:' + matches4.map(m => m[0] + '-' + m[1]).join(',')); await delay(2000);
let s2 = []; for (const m of matches4) { const w = await playMatch(m[0], m[1]); s2.push(w); addLog(`第 3 轮:${m[0]} vs ${m[1]} → ${w} 胜`); }
info.innerHTML = `<div class="sys">晋级名单:</div><div>${s2.join(' ')}</div>`; addLog('晋级名单:' + s2.join(' ')); await delay(2000);
info.innerHTML = '<div class="sys">第 4 轮(决赛)的比赛组合:</div>'; info.innerHTML += `<pre style="color:#e0e0e0;font-family:inherit;">${s2[0]} - ${s2[1]}\n</pre>`; addLog(`第 4 轮(决赛):${s2[0]} - ${s2[1]}`); await delay(2000);
const champion = await playMatch(s2[0], s2[1]); addLog(`冠军: ${champion}`);
clearScreen(); screen.appendChild(back); const t3 = document.createElement('div'); t3.className = 'menu-title'; t3.textContent = '晋级赛 - 冠军'; screen.appendChild(t3); const resDiv = document.createElement('div'); resDiv.className = 'result'; resDiv.textContent = `冠军是:${champion}!`; screen.appendChild(resDiv); screen.appendChild(renderLogBox());
const retry = document.createElement('button'); retry.className = 'skill-btn'; retry.textContent = '再来一局'; retry.onclick = () => startF5(); screen.appendChild(retry);
const backBtn = document.createElement('button'); backBtn.className = 'skill-btn'; backBtn.textContent = '返回主菜单'; backBtn.onclick = showMainMenu; screen.appendChild(backBtn);
updateLog();}
loadLogs();showMainMenu();</script></body></html>```
## AI使用说明本文的HTML版本代码系由 C++ 版本代码经 AI 工具DeepSeek V4.1-Flash-1017辅助转换与润色而成。