From 2d966b819844f9c2476415cf16035be2d6622c7e Mon Sep 17 00:00:00 2001 From: Kamal Tufekcic Date: Sun, 5 Jul 2026 12:14:39 +0300 Subject: [PATCH] initial commit --- .gitignore | 482 +++++++++++++++++++++++++ LICENSE | 661 +++++++++++++++++++++++++++++++++++ Pages/Faq.cshtml | 34 ++ Pages/Guides/Index.cshtml | 53 +++ Pages/Guides/Mode.cshtml | 103 ++++++ Pages/Guides/Mode.cshtml.cs | 41 +++ Pages/Index.cshtml | 62 ++++ Pages/Index.cshtml.cs | 21 ++ Pages/Leaderboard.cshtml | 62 ++++ Pages/Leaderboard.cshtml.cs | 11 + Pages/Privacy.cshtml | 12 + Pages/Rules.cshtml | 20 ++ Pages/Server.cshtml | 71 ++++ Pages/Server.cshtml.cs | 21 ++ Pages/Shared/_Layout.cshtml | 36 ++ Pages/Theory.cshtml | 217 ++++++++++++ Pages/Theory.cshtml.cs | 170 +++++++++ Pages/_ViewImports.cshtml | 3 + Pages/_ViewStart.cshtml | 3 + Program.cs | 15 + README.md | 23 ++ Services/Fleet.cs | 217 ++++++++++++ Services/Fmt.cs | 77 ++++ appsettings.Development.json | 5 + appsettings.json | 14 + cs2web.csproj | 10 + wwwroot/css/site.css | 185 ++++++++++ wwwroot/js/theory.js | 272 ++++++++++++++ 28 files changed, 2901 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 Pages/Faq.cshtml create mode 100644 Pages/Guides/Index.cshtml create mode 100644 Pages/Guides/Mode.cshtml create mode 100644 Pages/Guides/Mode.cshtml.cs create mode 100644 Pages/Index.cshtml create mode 100644 Pages/Index.cshtml.cs create mode 100644 Pages/Leaderboard.cshtml create mode 100644 Pages/Leaderboard.cshtml.cs create mode 100644 Pages/Privacy.cshtml create mode 100644 Pages/Rules.cshtml create mode 100644 Pages/Server.cshtml create mode 100644 Pages/Server.cshtml.cs create mode 100644 Pages/Shared/_Layout.cshtml create mode 100644 Pages/Theory.cshtml create mode 100644 Pages/Theory.cshtml.cs create mode 100644 Pages/_ViewImports.cshtml create mode 100644 Pages/_ViewStart.cshtml create mode 100644 Program.cs create mode 100644 README.md create mode 100644 Services/Fleet.cs create mode 100644 Services/Fmt.cs create mode 100644 appsettings.Development.json create mode 100644 appsettings.json create mode 100644 cs2web.csproj create mode 100644 wwwroot/css/site.css create mode 100644 wwwroot/js/theory.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0808c4a --- /dev/null +++ b/.gitignore @@ -0,0 +1,482 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from `dotnet new gitignore` + +# dotenv files +.env + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET +project.lock.json +project.fragment.lock.json +artifacts/ + +# Tye +.tye/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +# but not Directory.Build.rsp, as it configures directory-level build defaults +!Directory.Build.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml +.idea/ + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# content below from: https://github.com/github/gitignore/blob/main/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/main/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# Vim temporary swap files +*.swp diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..be3f7b2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/Pages/Faq.cshtml b/Pages/Faq.cshtml new file mode 100644 index 0000000..86bf7f8 --- /dev/null +++ b/Pages/Faq.cshtml @@ -0,0 +1,34 @@ +@page "/faq" +@{ + ViewData["Title"] = "FAQ"; +} + +

FAQ

+ +

The game warns me the server is "not secure" / has no VAC. Is my account safe?

+

+ Yes. VAC bans come from cheat software on your computer — never from joining any server. + Our servers deliberately run without VAC because the mod rewrites a large part of the game server-side + (damage scaling, stats, abilities, bot behavior), which is exactly the kind of deep modification VAC-secured + servers can't run. There are no human opponents here to cheat against anyway — it's you versus the bots. + Joining, playing, and leaving changes nothing about your standing on official servers. +

+ +

Is my progress saved?

+

+ Yes — XP, levels, prestige, and your stat build are stored per Steam account and shared across all our servers. + Match-scoped things (K/D, streaks, your Gun Game ladder position) reset when a match ends. +

+ +

How do I play? What do I press?

+

See the guides — short version: kill bots, type !skills, spend points, repeat.

+ +

Why can't I find the servers in the CS2 server browser?

+

+ Valve's community browser shows a small, ever-changing subset of thousands of servers — sometimes we're in it, + usually not. Use the join buttons on the front page, or add a favorite in-game with our + address and the port of the server you like. +

+ +

Something's broken / I have an idea

+

The mod is open source — issues and PRs welcome at the repository.

diff --git a/Pages/Guides/Index.cshtml b/Pages/Guides/Index.cshtml new file mode 100644 index 0000000..6d3e994 --- /dev/null +++ b/Pages/Guides/Index.cshtml @@ -0,0 +1,53 @@ +@page "/guides" +@{ + ViewData["Title"] = "Guides"; +} + +

How to play

+

+ Every mode shares the same RPG core: kill bots for XP, level up, spend skill points on permanent stats, + and at level 100, prestige — reset for a permanent XP boost and an unlocked ability. A per-player handicap + continuously scales difficulty to your power: the stronger you play, the harder the bots hit and the faster + you earn XP. Your HUD shows the live multipliers. +

+ +

Controls

+
+ Keys shown are the defaults: the shop opens on whatever use healthshot is bound to + (default X), and abilities cast on your grenade slot binds (default 6-0). + If you've rebound those, your binds apply — the mod listens to the actions, not the keys. +
+
+ + + + + +
InputWhat it does
X (healthshot)Opens/closes the quick-buy shop overlay (and the card draft in Survival)
1/2/3In the shop: pick primary / pistol / zeus option rows
6-0 (grenade keys)Cast an unlocked killstreak ability when it's ready
+
+ +

Chat commands

+

+ You only need to remember one: !commands prints this whole list + in game. Hover any command for what it does. +

+

+ !commands + !rank + !stats + !skills + !guns + !prestige + !abilities + !top + !hud + !dmg + !about +

+ +

Modes

+
+

TDM

Straight team deathmatch against the horde. First to the kill goal wins — and the bots are chasing the same goal.

+

Gun Game

Climb the weapon ladder; bots climb it too. Headshot deaths demote. Knife finale. The speedrun clock is on the leaderboard.

+

Survival

Endless waves, escalating difficulty, card drafts between waves. How deep can your squad go?

+
diff --git a/Pages/Guides/Mode.cshtml b/Pages/Guides/Mode.cshtml new file mode 100644 index 0000000..3825baa --- /dev/null +++ b/Pages/Guides/Mode.cshtml @@ -0,0 +1,103 @@ +@page "/guides/{mode}" +@using CsWeb.Services +@model CsWeb.Pages.Guides.ModeModel +@{ + ViewData["Title"] = $"{Fmt.ModeName(Model.Mode)} guide"; + var b = Model.B; +} + +

@Fmt.ModeName(Model.Mode)

+ +@if (b is null) +{ +
Live numbers unavailable right now (servers unreachable) — the prose still applies.
+} +else if (Model.Balance is { Online: false }) +{ +
Numbers below are from the last reachable server (@Fmt.Age(Model.Balance)).
+} + +@if (Model.Mode == "tdm") +{ +

+ Team deathmatch against the horde. Everyone respawns; the map ends when one player reaches the kill goal + @if (b is not null) { (currently @Fmt.IntOf(b.Match, "KillGoal") kills) } + — or when the bots do. Bot kills pool per squad-sized batch toward the same goal, so an ignored + horde genuinely wins the map: the pace scales with player count, and a lone player races exactly one batch. +

+

+ This is the mode with full loadout freedom — pick any primary and pistol with !guns or the + quick-buy shop, and swap mid-match whenever. It's also the purest read on your build: no ladder, no waves, + just you, the handicap, and a horde that shoots back harder the better you play. Brief spawn protection + keeps respawns from being feeding; it breaks the moment you attack. +

+} +else if (Model.Mode == "gungame") +{ +

+ Classic arms race with the RPG core riding along: advance a rung by getting kills with the current gun; + the ladder ends in a knife finale. Bots climb the same ladder — a bot topping it ends the + map, so you're racing them, not just each other. A headshot death demotes the victim one kill of progress — + and that cuts both ways: headshotting the bot pack slows their climb, catching a headshot costs you yours. +

+

+ Kills needed per rung follow the weapon's tier — weak guns take grinding, strong guns breeze — while the + bots run the inverse curve, so the race stays tight whether you're stuck on a Nova or cruising an + AK. Weapon selection is off (your rung is your gun), which makes Gun Game the skills-only mode: + the shop sells stat levels, nothing else. Your run time (first damage → final knife) goes on the + leaderboard; the clock survives reconnects, so there's no resetting a bad start. +

+ var ladder = Model.Ladder().ToList(); + @if (ladder.Count > 0) + { +

The ladder

+
+ + + @foreach (var (r, i) in ladder.Select((r, i) => (r, i))) + { + + } +
RungWeaponTier
@(i + 1)@Fmt.PrettyWeapon(r.Weapon)@r.Tier
+
+

Kills needed per rung scale with the weapon's tier — weak guns grind, strong guns breeze. Bots get the inverse curve.

+ } +} +else +{ +

+ Co-op waves@(b is not null ? $" (up to {Fmt.IntOf(b.Survival, "WaveCount")})" : "") of escalating + difficulty. Each wave has a kill budget; clear it and you get a breather — the fallen are revived, XP banks, + and the squad drafts cards. Nobody respawns mid-wave, and XP banks per cleared wave: + wipe halfway through and that wave's earnings are forfeit. Going down isn't the end (your squad can finish + the wave and pick you back up), but a full wipe ends the run. +

+

+ Cards are run-scoped upgrades stacking on top of your permanent build — strong on purpose, because the + difficulty ramp is relentless: the handicap's escalation floor climbs wave over wave until the bots hit you + at full force, and only a drafted-up squad outpaces it. The two team cards share one squad-wide level — + anyone's pick raises everyone's multiplier — so coordinating drafts beats hoarding. Your deepest cleared + wave goes on the leaderboard. +

+ var cards = Model.Cards().ToList(); + @if (cards.Count > 0) + { +

Card catalog

+
+ + + @foreach (var c in cards) + { + + + + + + + } +
CardPer pickMax picksNotes
@Fmt.StrOf(c, "Name")@Fmt.NumOf(c, "PerPick")@(Fmt.BoolOf(c, "Flat") ? "" : "%")@Fmt.IntOf(c, "Cap")@(Fmt.BoolOf(c, "IsTeam") ? "team-wide, shared level" : Fmt.CardDetail(Fmt.StrOf(c, "Detail"), Fmt.NumOf(c, "PerPick")))
+
+ } +} + +

Theory has the full stat tables and the handicap math behind all of this.

diff --git a/Pages/Guides/Mode.cshtml.cs b/Pages/Guides/Mode.cshtml.cs new file mode 100644 index 0000000..12a453a --- /dev/null +++ b/Pages/Guides/Mode.cshtml.cs @@ -0,0 +1,41 @@ +using System.Text.Json; +using CsWeb.Services; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace CsWeb.Pages.Guides; + +public class ModeModel(Fleet fleet) : PageModel +{ + private static readonly string[] Known = ["tdm", "gungame", "survival"]; + + public string Mode { get; private set; } = ""; + public Cached? Balance { get; private set; } + public BalancePayload? B => Balance?.Data; + + public async Task OnGetAsync(string mode) + { + mode = mode.ToLowerInvariant(); + if (!Known.Contains(mode)) return NotFound(); + Mode = mode; + (_, Balance) = await fleet.BalanceForMode(mode); + return Page(); + } + + // The GG ladder rows from the balance payload's GunGame.Ladder ([{Weapon, Tier}]). + public IEnumerable<(string Weapon, int Tier)> Ladder() + { + if (B is null || B.GunGame.ValueKind != JsonValueKind.Object) yield break; + if (!B.GunGame.TryGetProperty("Ladder", out var l) || l.ValueKind != JsonValueKind.Array) yield break; + foreach (var e in l.EnumerateArray()) + yield return (Fmt.StrOf(e, "Weapon"), Fmt.IntOf(e, "Tier")); + } + + // Survival card catalog rows ([{Key, Name, PerPick, Cap, Flat?, IsTeam?, Detail?}] — tolerant of shape drift). + public IEnumerable Cards() + { + if (B is null || B.Survival.ValueKind != JsonValueKind.Object) yield break; + if (!B.Survival.TryGetProperty("Cards", out var c) || c.ValueKind != JsonValueKind.Array) yield break; + foreach (var e in c.EnumerateArray()) yield return e; + } +} diff --git a/Pages/Index.cshtml b/Pages/Index.cshtml new file mode 100644 index 0000000..c8846c0 --- /dev/null +++ b/Pages/Index.cshtml @@ -0,0 +1,62 @@ +@page +@using CsWeb.Services +@model IndexModel +@{ + ViewData["Title"] = ""; +} +@section Meta { + + + +} + +

Outnumbered

+

+ A players-vs-bots RPG mod for CS2: you and a few humans versus a scaling horde. Kill for XP, level up, + spend points on permanent stats, prestige for keeps — across three modes. No matchmaking, no ranks lost, + no teenagers screaming into your ear. Pick a server and shoot something. +

+

+ These servers run deliberately without VAC (it's a PvE mod that rewrites half the game). + Your account is safe — see the FAQ. +

+ +@if (Model.Servers.Count == 0) +{ +
No servers found. If you just deployed, the game instances may still be starting.
+} +
+@foreach (var (id, s) in Model.Servers) +{ + var d = s.Data; +
+
+

@(d?.Hostname is { Length: > 0 } h ? h : id)

+ @if (!s.Online) { offline } + else { @Fmt.ModeName(d?.Mode) } +
+ @if (d is not null) + { +
+ @d.Map + @d.Humans.Count/@d.MaxHumans players · @d.Bots bots +
+ @if (Fmt.ExtraLine(d) is { Length: > 0 } extra) + { +
@extra
+ } + @if (d.Port > 0) + { +
+ connect @Model.Fleet.PublicHost:@d.Port + Join +
+ } + } + else + { +
@Fmt.Age(s)
+ } +
+} +
diff --git a/Pages/Index.cshtml.cs b/Pages/Index.cshtml.cs new file mode 100644 index 0000000..481ec84 --- /dev/null +++ b/Pages/Index.cshtml.cs @@ -0,0 +1,21 @@ +using CsWeb.Services; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace CsWeb.Pages; + +public class IndexModel(Fleet fleet) : PageModel +{ + public Fleet Fleet => fleet; + public List<(string Id, Cached Status)> Servers { get; private set; } = []; + public int HumansOnline { get; private set; } + public int ServersUp { get; private set; } + + public async Task OnGetAsync() + { + var ids = fleet.Instances(); + var fetched = await Task.WhenAll(ids.Select(fleet.Status)); + Servers = ids.Zip(fetched, (id, s) => (id, s)).ToList(); + HumansOnline = Servers.Sum(s => s.Status.Online ? s.Status.Data?.Humans.Count ?? 0 : 0); + ServersUp = Servers.Count(s => s.Status.Online); + } +} diff --git a/Pages/Leaderboard.cshtml b/Pages/Leaderboard.cshtml new file mode 100644 index 0000000..35d4d16 --- /dev/null +++ b/Pages/Leaderboard.cshtml @@ -0,0 +1,62 @@ +@page "/leaderboard" +@using CsWeb.Services +@model LeaderboardModel +@{ + ViewData["Title"] = "Leaderboard"; + var t = Model.Top; + var d = t?.Data; +} + +

Leaderboard

+@if (t is null || d is null) +{ +
Leaderboards are unavailable right now (no server reachable).
+} +else +{ + @if (!t.Online) + { +
Servers are offline — showing the last known standings (@Fmt.Age(t)).
+ } +
+
+

Progression

+
+ + + @foreach (var (r, i) in d.Levels.Select((r, i) => (r, i))) + { + + } +
#PlayerPrestigeLevel
@(i + 1)@r.Name@r.Prestige@r.Level
+
+
+
+

Deepest survival wave

+
+ + + @foreach (var (r, i) in d.Waves.Select((r, i) => (r, i))) + { + + } + @if (d.Waves.Count == 0) { } +
#PlayerWave
@(i + 1)@r.Name@r.BestWave
No cleared waves recorded yet.
+
+
+
+

Fastest Gun Game

+
+ + + @foreach (var (r, i) in d.GgTimes.Select((r, i) => (r, i))) + { + + } + @if (d.GgTimes.Count == 0) { } +
#PlayerTime
@(i + 1)@r.Name@Fmt.RunTime(r.BestMs)
No full ladder runs recorded yet.
+
+
+
+

The clock starts at your first damage dealt or taken after joining — reconnecting doesn't reset it.

+} diff --git a/Pages/Leaderboard.cshtml.cs b/Pages/Leaderboard.cshtml.cs new file mode 100644 index 0000000..f90b523 --- /dev/null +++ b/Pages/Leaderboard.cshtml.cs @@ -0,0 +1,11 @@ +using CsWeb.Services; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace CsWeb.Pages; + +public class LeaderboardModel(Fleet fleet) : PageModel +{ + public Cached? Top { get; private set; } + + public async Task OnGetAsync() => Top = await fleet.Top(); +} diff --git a/Pages/Privacy.cshtml b/Pages/Privacy.cshtml new file mode 100644 index 0000000..598a675 --- /dev/null +++ b/Pages/Privacy.cshtml @@ -0,0 +1,12 @@ +@page "/privacy" +@{ + ViewData["Title"] = "Privacy"; +} + +

Privacy

+

+ The game servers store your SteamID, display name, and gameplay statistics (XP, levels, records) to make + progression and leaderboards work; this website reads that data and stores nothing of its own, sets no cookies, + and runs no trackers or analytics. To have your data removed, contact the operator via + the repository. +

diff --git a/Pages/Rules.cshtml b/Pages/Rules.cshtml new file mode 100644 index 0000000..215a0c7 --- /dev/null +++ b/Pages/Rules.cshtml @@ -0,0 +1,20 @@ +@page "/rules" +@{ + ViewData["Title"] = "Rules"; +} + +

Rules

+

It's PvE. There isn't much to ruin — but the little there is, don't:

+
    +
  • No cheats or automation. Yes, even against bots — the leaderboards are shared.
  • +
  • No leaderboard griefing (win-trading the Gun Game timer, farming an empty server with exploits).
  • +
  • Keep chat civil. The entire point of this place is not having to mute anyone.
  • +
  • Exploits and crashes: report them, don't farm them.
  • +
+

Breaking these gets your progress wiped and/or a ban. There is no appeals process; there is one admin.

+ +

Wipes

+

+ No scheduled wipes. Balance changes happen live and are listed in the changelog; + if a change ever requires a reset (unlikely), it will be announced here first. +

diff --git a/Pages/Server.cshtml b/Pages/Server.cshtml new file mode 100644 index 0000000..4f4a69f --- /dev/null +++ b/Pages/Server.cshtml @@ -0,0 +1,71 @@ +@page "/s/{id}" +@using CsWeb.Services +@model ServerModel +@{ + var s = Model.Status!; + var d = s.Data; + var title = d?.Hostname is { Length: > 0 } h ? h : Model.Id; + ViewData["Title"] = title; + var ogDesc = d is null + ? "Outnumbered CS2 server" + : $"{Fmt.ModeName(d.Mode)} on {d.Map} — {d.Humans.Count}/{d.MaxHumans} players, {d.Bots} bots." + + (Fmt.ExtraLine(d) is { Length: > 0 } ex ? $" {ex}." : ""); +} +@section Meta { + + + +} + +

@title

+

+ @Fmt.ModeName(d?.Mode) + @if (!s.Online) { @Fmt.Age(s) } +

+ +@if (d is null) +{ +
This server hasn't reported yet. If it just started, give it a few seconds.
+} +else +{ +
+

+ Map @d.Map · @d.Humans.Count/@d.MaxHumans players · @d.Bots bots + @if (Fmt.ExtraLine(d) is { Length: > 0 } extra) { · @extra } +

+
+ @if (d.Port > 0) + { +

+ Join now +   or paste in console: connect @Model.Fleet.PublicHost:@d.Port +

+ } + + @if (d.Humans.Count > 0) + { +

Players

+
+ + + + + @if (d.Mode == "gungame") { } + + @foreach (var p in d.Humans) + { + + + + @if (d.Mode == "gungame") { } + + } +
NameLevelPrestigeKDStreakWeapon
@p.Name@p.Level@p.Prestige@p.Kills@p.Deaths@p.Streak@(Fmt.RungWeapon(d, p) ?? "—")
+
+ } + else + { +

Nobody in game right now — free server, all yours.

+ } +} diff --git a/Pages/Server.cshtml.cs b/Pages/Server.cshtml.cs new file mode 100644 index 0000000..447fd7d --- /dev/null +++ b/Pages/Server.cshtml.cs @@ -0,0 +1,21 @@ +using CsWeb.Services; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace CsWeb.Pages; + +public class ServerModel(Fleet fleet) : PageModel +{ + public Fleet Fleet => fleet; + public string Id { get; private set; } = ""; + public Cached? Status { get; private set; } + + public async Task OnGetAsync(string id) + { + // The slug space is exactly the socket names — anything else 404s before touching a socket path. + if (!fleet.Instances().Contains(id)) return NotFound(); + Id = id; + Status = await fleet.Status(id); + return Page(); + } +} diff --git a/Pages/Shared/_Layout.cshtml b/Pages/Shared/_Layout.cshtml new file mode 100644 index 0000000..3941bc2 --- /dev/null +++ b/Pages/Shared/_Layout.cshtml @@ -0,0 +1,36 @@ + + + + + + + @(ViewData["Title"] is string t && t.Length > 0 ? $"{t} — cs2-on.eu" : "cs2-on.eu — Outnumbered CS2 PvE RPG") + @RenderSection("Meta", required: false) + + + +
+ +
+
+ @RenderBody() +
+ + @RenderSection("Scripts", required: false) + + diff --git a/Pages/Theory.cshtml b/Pages/Theory.cshtml new file mode 100644 index 0000000..d16ef26 --- /dev/null +++ b/Pages/Theory.cshtml @@ -0,0 +1,217 @@ +@page "/theory" +@using CsWeb.Services +@model TheoryModel +@{ + ViewData["Title"] = "Theorycrafting"; + var b = Model.B; +} + +

Theorycrafting

+

+ Numbers below are live — read from the running servers' effective config, including any + hot-reloaded balance tuning. The curves are computed by the same compiled code that scales damage in game. + Everything is also editable: change any knob to explore; Reset returns to server values. +

+

+ Showing values for @Fmt.ModeName(b?.Mode) — + view for TDM · Gun Game · Survival + (modes can override handicap bands). +

+ +@if (b is null) +{ +
No server reachable right now — theory needs a live config to be honest. Try again shortly.
+} +else +{ + @if (Model.ModeMismatch) + { +
No @Fmt.ModeName(Model.ModeParam) server is reachable right now — showing @Fmt.ModeName(b.Mode) values (the only live config available).
+ } + @if (Model.Balance is { Online: false }) + { +
Servers offline — showing the last known config (@Fmt.Age(Model.Balance!)).
+ } + +

The handicap

+

+ One signed index t summarizes how dominant you are (K/D, headshot rate, killstreak, level, and the + mode's progress axis, weighted and eased). t = 0 is neutral; +1 is fully dominant; + −1 is struggling. All three multipliers are driven by the same t, so they hit their extremes together: + dominate and you deal less, take more, and level faster — all at once. +

+ + @if (Model.Panels.Count > 0) + { +
+
+ + t = 0.00 + @foreach (var p in Model.Panels) + { + ×1.00 + } + dashed green line = your simulated player +
+ @foreach (var (p, i) in Model.Panels.Select((p, i) => (p, i))) + { + var last = i == Model.Panels.Count - 1; + var height = TheoryModel.T + TheoryModel.PlotH + (last ? 26 : 8); + + @p.Title + + + + @p.YMax.ToString("0.#") + ×1 + 0 + + + + @if (last) + { + @* SVG collides with Razor's literal pseudo-tag inside code blocks -> raw emit *@ + foreach (var tv in new[] { -1.0, -0.5, 0.0, 0.5, 1.0 }) + { + var x = TheoryModel.L + (tv + 1) / 2 * Model.PlotW; + @Html.Raw($"{tv:0.#}") + } + } + + } +
← struggling  ·  t  ·  dominant →   (drag the slider or hover the chart; curves follow your edits below)
+
+ } + +

Simulator

+

+ Seeded from the live server config. Edit anything — player state, stat levels, card picks, handicap knobs — + and every readout and curve recomputes. Abilities, crits and headshots are excluded (parity with the in-game + HUD's base readout). Edited fields get an amber outline. +

+ +
+
+ index0.00 + deal band×1.00 + take band×1.00 + xp band×1.00 + Out × (with stats)×1.00 + In ××1.00 + HS ××1.00 + XP × (total)×1.00 + +
+ +
+ Player state +
+ + + + + + + + +
+
+ +
+
+ Stat tree (invested levels) +
+ + + @foreach (var s in Model.StatRows()) + { + + + + + + + + } +
StatBasePer lvlInvestedEffective
@s.Name@s.Base@s.PerLevel@s.Base
+
+
+ +
+
+ Survival cards (run-scoped picks) +
+ + + @foreach (var c in Model.CardRows()) + { + dynamic card = c; + + + + + + } +
CardPer pickPicks
@card.Name @(card.IsTeam ? Html.Raw("team") : Html.Raw(""))@card.PerPick
+
+
+ +
+ XP +
+ +
+
+
+
+ +
+ Handicap knobs (@Fmt.ModeName(b.Mode) effective) +
+ @foreach (var (group, rows) in Model.HandicapGroups()) + { +
+

@group

+ @foreach (var r in rows) + { + if (r.IsBool) + { + + } + else + { + + } + } +
+ } +
+
+
+ +

Key points (server values)

+
+ + + @foreach (var r in Model.KeyRows()) + { + + + + + + + } +
tDeal ×Take ×XP ×
@r.T.ToString("0.0")@r.Deal.ToString("0.00")@r.Take.ToString("0.00")@r.Xp.ToString("0.00")
+
+ +

+ Weapon-by-weapon time-to-kill tables and per-weapon damage simulation are planned on top of this. +

+ + +} + +@section Scripts { + +} diff --git a/Pages/Theory.cshtml.cs b/Pages/Theory.cshtml.cs new file mode 100644 index 0000000..f84b44d --- /dev/null +++ b/Pages/Theory.cshtml.cs @@ -0,0 +1,170 @@ +using System.Globalization; +using System.Text; +using System.Text.Json; +using CsWeb.Services; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace CsWeb.Pages; + +public class TheoryModel(Fleet fleet) : PageModel +{ + // Panel geometry in viewBox units (SVG scales to container width). + public const int W = 720, PlotH = 134, L = 46, R = 10, T = 10; + public int PlotW => W - L - R; + + public sealed record Panel(string Key, string Title, string Color, string Points, double YMax, double OneY); + + public string? ModeParam { get; private set; } + public Cached? Balance { get; private set; } + public BalancePayload? B => Balance?.Data; + public List Panels { get; } = []; + public string SimJson { get; private set; } = "null"; + public double PrestigeBoostPercent { get; private set; } // server value, rendered into the input (no-JS honesty) + + // A requested mode with no live server of that mode falls back to whatever IS reachable — say so explicitly, + // because the effective handicap genuinely differs per mode. + public bool ModeMismatch => + !string.IsNullOrEmpty(ModeParam) && B is not null + && !string.Equals(ModeParam, B.Mode, StringComparison.OrdinalIgnoreCase); + + // Balance serializes StatsConfig with PascalCase property names; the domain (and the survival cards) key stats + // by snake_case ids. This is the one place the site maps between them (mirror of the plugin's StatRegistry). + private static readonly (string Prop, string Key, string Display)[] StatMap = + [ + ("Damage", "damage", "Damage"), + ("CritChance", "crit_chance", "Crit Chance"), + ("CritDamage", "crit_damage", "Crit Damage"), + ("HeadshotDamage", "hs_damage", "Headshot Damage"), + ("MaxHp", "max_hp", "Max HP"), + ("MaxArmor", "max_armor", "Max Armor"), + ("Lifesteal", "lifesteal", "Lifesteal"), + ("ArmorLifesteal", "armor_lifesteal", "Armor Lifesteal"), + ("HpRegen", "hp_regen", "HP Regen"), + ("ArmorRegen", "armor_regen", "Armor Regen"), + ("Thorns", "thorns", "Thorns"), + ("XpBoost", "xp_boost", "XP Boost"), + ]; + + public async Task OnGetAsync(string? mode) + { + ModeParam = mode; + (_, Balance) = await fleet.BalanceForMode(mode ?? ""); + var c = B?.Curves; + if (c is null || c.T.Length < 2) return; + + // Fixed slot order (validated categorical palette, dark surface): identity is carried by each panel's title; + // the hue only ties the panel to its slider readout. + Panels.Add(BuildPanel("deal", "Damage dealt ×", "#3987e5", c.Deal)); + Panels.Add(BuildPanel("take", "Damage taken ×", "#199e70", c.Take)); + Panels.Add(BuildPanel("xp", "XP rate ×", "#c98500", c.Xp)); + + // The simulator's seed: everything the JS math needs, in one blob. Server values = the reset state. + PrestigeBoostPercent = Fmt.NumOf(B!.Progression, "PrestigeXpBoostPercent"); + SimJson = JsonSerializer.Serialize(new + { + Curves = c, + Handicap = HandicapRows().ToDictionary(r => r.Name, r => r.Num), + Stats = StatRows().Select(s => new { s.Key, s.Name, s.Base, s.PerLevel, s.MaxLevel }).ToList(), + Cards = CardRows().ToList(), + PrestigeBoostPercent, + }); + } + + // Survival cards that the simulator can apply: stat-keyed cards (card key == stat key) + the two team cards. + public IEnumerable CardRows() + { + if (B is null || B.Survival.ValueKind != JsonValueKind.Object) yield break; + if (!B.Survival.TryGetProperty("Cards", out var cards) || cards.ValueKind != JsonValueKind.Array) yield break; + foreach (var e in cards.EnumerateArray()) + { + string key = Fmt.StrOf(e, "Key"); + bool isTeam = Fmt.BoolOf(e, "IsTeam"); + if (!isTeam && !StatMap.Any(m => m.Key == key)) continue; // effect cards (burn/explode/...) aren't stat math + yield return new + { + Key = key, + Name = Fmt.StrOf(e, "Name"), + PerPick = Fmt.NumOf(e, "PerPick"), + Cap = Fmt.IntOf(e, "Cap"), + IsTeam = isTeam, + }; + } + } + + private Panel BuildPanel(string key, string title, string color, double[] ys) + { + double max = ys.Max(); + double step = max <= 2 ? 0.5 : max <= 5 ? 1 : 2; + double ymax = Math.Max(step, Math.Ceiling(max / step) * step); + + var sb = new StringBuilder(ys.Length * 12); + for (int i = 0; i < ys.Length; i++) + { + double x = L + (double)i / (ys.Length - 1) * PlotW; + double y = T + PlotH * (1 - ys[i] / ymax); + if (i > 0) sb.Append(' '); + sb.Append(x.ToString("0.#", CultureInfo.InvariantCulture)).Append(',') + .Append(y.ToString("0.#", CultureInfo.InvariantCulture)); + } + double oneY = T + PlotH * (1 - 1.0 / ymax); // the ×1 neutral reference line + return new Panel(key, title, color, sb.ToString(), ymax, oneY); + } + + public double YFor(Panel p, double value) => T + PlotH * (1 - value / p.YMax); + + // The table view of the chart (accessibility + skim value): the five canonical t anchors. + public IEnumerable<(double T, double Deal, double Take, double Xp)> KeyRows() + { + var c = B?.Curves; + if (c is null || c.T.Length < 201) yield break; + foreach (int i in new[] { 0, 50, 100, 150, 200 }) + yield return (c.T[i], c.Deal[i], c.Take[i], c.Xp[i]); + } + + // Stat-tree rows in registry order, joined against the live Stats block (unmapped/new stats fall back to raw name). + public IEnumerable<(string Key, string Name, double Base, double PerLevel, int MaxLevel)> StatRows() + { + if (B is null || B.Stats.ValueKind != JsonValueKind.Object) yield break; + foreach (var p in B.Stats.EnumerateObject()) + { + if (p.Value.ValueKind != JsonValueKind.Object || !p.Value.TryGetProperty("MaxLevel", out _)) continue; + var m = StatMap.FirstOrDefault(m => m.Prop == p.Name); + yield return (m.Key ?? p.Name.ToLowerInvariant(), m.Display ?? p.Name, + Fmt.NumOf(p.Value, "Base"), Fmt.NumOf(p.Value, "PerLevel"), Fmt.IntOf(p.Value, "MaxLevel")); + } + } + + // Every scalar knob of the effective (mode-resolved) handicap block, as-is — drift-proof by construction. + // Bools ride as 0/1 so the whole block is one editable numeric dictionary for the simulator. + public IEnumerable<(string Name, double Num, bool IsBool)> HandicapRows() + { + if (B is null || B.EffectiveHandicap.ValueKind != JsonValueKind.Object) yield break; + foreach (var p in B.EffectiveHandicap.EnumerateObject()) + { + switch (p.Value.ValueKind) + { + case JsonValueKind.Number: yield return (p.Name, p.Value.GetDouble(), false); break; + case JsonValueKind.True: yield return (p.Name, 1, true); break; + case JsonValueKind.False: yield return (p.Name, 0, true); break; + } + } + } + + // Knob display grouping — name-shape rules so future knobs sort themselves (unknowns land in Thresholds). + private static string GroupOf(string name) => + name is "Enabled" or "MasterDifficulty" or "Curve" ? "Core" + : name.EndsWith("Weight", StringComparison.Ordinal) ? "Factor weights" + : name.StartsWith("MDeal", StringComparison.Ordinal) || name.StartsWith("MTake", StringComparison.Ordinal) + || name.StartsWith("Xp", StringComparison.Ordinal) ? "Bands" + : "Thresholds"; + + private static readonly string[] GroupOrder = ["Core", "Thresholds", "Factor weights", "Bands"]; + + public IEnumerable<(string Group, List<(string Name, double Num, bool IsBool)> Rows)> HandicapGroups() => + HandicapRows().GroupBy(r => GroupOf(r.Name)) + .OrderBy(g => Array.IndexOf(GroupOrder, g.Key) is var i && i < 0 ? int.MaxValue : i) + .Select(g => (g.Key, g.ToList())); + + // Spinner step by magnitude, so Curve 0.8 steps by 0.05 instead of the browser default 1 (typing stays free-form). + public static string StepFor(double v) => Math.Abs(v) < 1 ? "0.05" : Math.Abs(v) < 10 ? "0.1" : "1"; +} diff --git a/Pages/_ViewImports.cshtml b/Pages/_ViewImports.cshtml new file mode 100644 index 0000000..6af674e --- /dev/null +++ b/Pages/_ViewImports.cshtml @@ -0,0 +1,3 @@ +@using CsWeb +@namespace CsWeb.Pages +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/Pages/_ViewStart.cshtml b/Pages/_ViewStart.cshtml new file mode 100644 index 0000000..820a2f6 --- /dev/null +++ b/Pages/_ViewStart.cshtml @@ -0,0 +1,3 @@ +@{ + Layout = "_Layout"; +} diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..2c43805 --- /dev/null +++ b/Program.cs @@ -0,0 +1,15 @@ +using CsWeb.Services; + +var builder = WebApplication.CreateBuilder(args); +builder.Services.AddRazorPages(); +builder.Services.AddSingleton(); + +var app = builder.Build(); +app.UseStaticFiles(); +app.MapRazorPages(); + +// Changelog is deliberately not a page: the Forgejo releases feed IS the changelog (one source of truth). +app.MapGet("/changelog", (IConfiguration cfg) => + Results.Redirect(cfg["Outnumbered:ReleasesUrl"] ?? "/", permanent: false)); + +await app.RunAsync(); diff --git a/README.md b/README.md new file mode 100644 index 0000000..9bf42f7 --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# cs2-web + +The companion website for [cs2-on.eu](https://cs2-on.eu) — server status, leaderboards, guides, and a +theorycrafting page for the **Outnumbered** CS2 PvE RPG mod. You're probably looking for the mod itself: +**[cs2-outnumbered](https://git.lo.sh/kamal/cs2-outnumbered)**. This repo exists for transparency; the site +is only useful with running Outnumbered servers to talk to. + +## What it is + +ASP.NET Core Razor Pages, zero external packages, no JS framework, no build pipeline. The site is stateless +and owns no data: each game server's plugin exposes a local Unix-domain-socket API (`status` / `balance` / +`top`), and the site renders whatever those report — live status, DB-backed leaderboards, and the effective +balance config (the theorycrafting curves are computed by the same code that scales damage in game, so the +published numbers can't drift from reality). No cookies, no trackers, no analytics. + +## Running it + +```sh +ASPNETCORE_ENVIRONMENT=Development dotnet run # expects sockets in /tmp/og-sock (see appsettings.Development.json) +``` + +Point `Outnumbered:SocketDir` at a directory of Outnumbered API sockets and open http://127.0.0.1:5080. +Without any sockets it renders empty/offline states, which is all it can honestly do. diff --git a/Services/Fleet.cs b/Services/Fleet.cs new file mode 100644 index 0000000..407a596 --- /dev/null +++ b/Services/Fleet.cs @@ -0,0 +1,217 @@ +using System.Net.Sockets; +using System.Text; +using System.Text.Json; + +namespace CsWeb.Services; + +// ---- wire DTOs (mirror the plugin's Api.cs payloads, PascalCase, schema-versioned) ---- + +public sealed class HumanRow +{ + public string Name { get; init; } = ""; + public int Level { get; init; } + public int Prestige { get; init; } + public int Kills { get; init; } + public int Deaths { get; init; } + public int Streak { get; init; } + public int Rung { get; init; } +} + +public sealed class StatusPayload +{ + public int V { get; init; } + public long GeneratedAtMs { get; init; } + public string ServerId { get; init; } = ""; + public string Mode { get; init; } = ""; + public string Map { get; init; } = ""; + public string Hostname { get; init; } = ""; + public int Port { get; init; } + public int MaxHumans { get; init; } + public int Bots { get; init; } + public List Humans { get; init; } = []; + public JsonElement Extra { get; init; } // mode-specific block (survival wave, GG ladder, TDM kill goal) +} + +public sealed class CurvesDto +{ + public double[] T { get; init; } = []; + public double[] Deal { get; init; } = []; + public double[] Take { get; init; } = []; + public double[] Xp { get; init; } = []; +} + +public sealed class BalancePayload +{ + public int V { get; init; } + public long GeneratedAtMs { get; init; } + public string ServerId { get; init; } = ""; + public string Mode { get; init; } = ""; + public JsonElement Match { get; init; } + public JsonElement Stats { get; init; } + public JsonElement Progression { get; init; } + public JsonElement Abilities { get; init; } + public JsonElement GunGame { get; init; } + public JsonElement Survival { get; init; } + public JsonElement EffectiveHandicap { get; init; } + public CurvesDto? Curves { get; init; } +} + +public sealed class TopLevelRow { public string Name { get; init; } = ""; public int Level { get; init; } public int Prestige { get; init; } public long Xp { get; init; } } +public sealed class TopWaveRow { public string Name { get; init; } = ""; public int BestWave { get; init; } } +public sealed class TopGgRow { public string Name { get; init; } = ""; public long BestMs { get; init; } } + +public sealed class TopPayload +{ + public int V { get; init; } + public long GeneratedAtMs { get; init; } + public List Levels { get; init; } = []; + public List Waves { get; init; } = []; + public List GgTimes { get; init; } = []; +} + +// A cached fetch: the site is stateless by design, so RAM-last-good is the ONLY persistence. A dead socket serves +// the previous payload with Online=false instead of a blank page (the servers being briefly down must not blank the site). +public sealed class Cached where T : class +{ + public T? Data { get; set; } + public DateTimeOffset FetchedAt { get; set; } // when Data was last refreshed successfully + public DateTimeOffset LastAttempt { get; set; } + public bool Online { get; set; } + public TimeSpan Age => DateTimeOffset.UtcNow - FetchedAt; +} + +// The one data source of the whole site: the per-instance Unix domain sockets served by the plugin +// (verbs status/balance/top -> one JSON payload, connection closes). Instance discovery = globbing the socket dir, +// so a stopped server simply drops off the fleet. All caches are per-verb TTLs with last-good retention; a duplicate +// concurrent fetch is acceptable (traffic is tiny) so there is deliberately no per-key locking. +public sealed class Fleet(IConfiguration cfg, ILogger log) +{ + private static readonly TimeSpan StatusTtl = TimeSpan.FromSeconds(3); + private static readonly TimeSpan BalanceTtl = TimeSpan.FromSeconds(30); + private static readonly TimeSpan TopTtl = TimeSpan.FromSeconds(30); + private static readonly TimeSpan IoTimeout = TimeSpan.FromSeconds(1); + + private readonly string _socketDir = cfg["Outnumbered:SocketDir"] ?? "/run/outnumbered"; + private readonly Dictionary> _status = new(); + private readonly Dictionary> _balance = new(); + private readonly Cached _top = new(); + + public string PublicHost { get; } = cfg["Outnumbered:PublicHost"] ?? "localhost"; + + // The live fleet = the socket files. Sorted for a stable card order. + public IReadOnlyList Instances() + { + try + { + return Directory.Exists(_socketDir) + ? Directory.GetFiles(_socketDir, "*.sock").Select(Path.GetFileNameWithoutExtension).Where(n => n is not null).Select(n => n!).Order().ToList() + : []; + } + catch (Exception ex) { log.LogWarning(ex, "socket dir scan failed"); return []; } + } + + public Task> Status(string id) => Get(_status, id, "status", StatusTtl); + public Task> Balance(string id) => Get(_balance, id, "balance", BalanceTtl); + + // Leaderboards are global DB data — any live instance answers identically, so ask down the list until one does. + public async Task> Top() + { + lock (_top) + { + if (DateTimeOffset.UtcNow - _top.LastAttempt < TopTtl) return _top; + _top.LastAttempt = DateTimeOffset.UtcNow; // stamped before the fetch: a failing socket is retried at TTL pace, not per request + } + foreach (var id in Instances()) + { + var p = await Query(id, "top"); + if (p is not null) + { + lock (_top) + { + _top.Data = p; + _top.FetchedAt = DateTimeOffset.UtcNow; + _top.Online = true; + } + return _top; + } + } + lock (_top) { _top.Online = false; } + return _top; + } + + // Balance is per-instance (mode-effective config): for a mode page, prefer an instance actually RUNNING that mode. + // Pick order: live mode match > stale mode match (right CONTENT beats fresh-but-wrong-mode) > any live instance > + // any instance with a last-good cache > any socket at all. A dead socket file (crash leftover, sorts first) can + // never shadow a live server, and a crashed right-mode instance still serves its cached balance. + public async Task<(string? Id, Cached? Balance)> BalanceForMode(string mode) + { + string? first = null, firstOnline = null, firstWithData = null, staleModeMatch = null; + foreach (var id in Instances()) + { + first ??= id; + var s = await Status(id); + if (s.Data is null) continue; // never answered — dead socket file + firstWithData ??= id; + bool match = string.Equals(s.Data.Mode, mode, StringComparison.OrdinalIgnoreCase); + if (s.Online) + { + firstOnline ??= id; + if (match) return (id, await Balance(id)); + } + else if (match) staleModeMatch ??= id; + } + var pick = staleModeMatch ?? firstOnline ?? firstWithData ?? first; + return pick is null ? (null, null) : (pick, await Balance(pick)); + } + + private async Task> Get(Dictionary> map, string id, string verb, TimeSpan ttl) where T : class + { + Cached c; + lock (map) { if (!map.TryGetValue(id, out c!)) map[id] = c = new Cached(); } + lock (c) + { + if (DateTimeOffset.UtcNow - c.LastAttempt < ttl) return c; + c.LastAttempt = DateTimeOffset.UtcNow; // stamped before the fetch: a dead socket is retried at TTL pace, not per request + } + var p = await Query(id, verb); + lock (c) + { + c.Online = p is not null; + if (p is not null) + { + c.Data = p; + c.FetchedAt = DateTimeOffset.UtcNow; + } + } + return c; + } + + // One request/response round trip: verb line in, full payload out, peer closes. An {"Err":...} payload (server + // booting, DB down) counts as a miss — last-good keeps serving. + private async Task Query(string id, string verb) where T : class + { + try + { + using var cts = new CancellationTokenSource(IoTimeout); + using var sock = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.Unspecified); + await sock.ConnectAsync(new UnixDomainSocketEndPoint(Path.Combine(_socketDir, id + ".sock")), cts.Token); + await sock.SendAsync(Encoding.ASCII.GetBytes(verb + "\n"), SocketFlags.None, cts.Token); + + using var ms = new MemoryStream(); + var buf = new byte[16384]; + int n; + while ((n = await sock.ReceiveAsync(buf, SocketFlags.None, cts.Token)) > 0) + ms.Write(buf, 0, n); + + if (ms.Length == 0) return null; + using var doc = JsonDocument.Parse(ms.GetBuffer().AsMemory(0, (int)ms.Length)); + if (doc.RootElement.TryGetProperty("Err", out _)) return null; + return doc.RootElement.Deserialize(); + } + catch (Exception ex) + { + log.LogDebug(ex, "query {Verb} on {Id} failed", verb, id); + return null; + } + } +} diff --git a/Services/Fmt.cs b/Services/Fmt.cs new file mode 100644 index 0000000..1b321d0 --- /dev/null +++ b/Services/Fmt.cs @@ -0,0 +1,77 @@ +using System.Text.Json; + +namespace CsWeb.Services +{ + // View helpers: tiny, dependency-free formatting shared by the pages. Content-only — no markup decisions here. + public static class Fmt + { + public static string ModeName(string? mode) => mode?.ToLowerInvariant() switch + { + "tdm" => "TDM", + "gungame" => "Gun Game", + "survival" => "Survival", + _ => mode ?? "?", + }; + + // Matches the plugin's win-banner format (m:ss.fff). + public static string RunTime(long ms) => $"{ms / 60000}:{ms / 1000 % 60:D2}.{ms % 1000:D3}"; + + public static string Age(Cached c) where T : class => + c.Data is null ? "no data yet" + : c.Online ? "live" + : $"last seen {(int)c.Age.TotalSeconds}s ago"; + + // One-line mode summary for a server card, from the status payload's mode-specific Extra block. + public static string ExtraLine(StatusPayload s) + { + var e = s.Extra; + if (e.ValueKind != JsonValueKind.Object) return ""; + return s.Mode switch + { + "survival" when e.TryGetProperty("RunActive", out var run) && run.GetBoolean() + && e.TryGetProperty("Wave", out var w) && e.TryGetProperty("WaveCount", out var wc) + => $"Wave {w.GetInt32()}/{wc.GetInt32()}", + "survival" => "Between runs", + "gungame" when e.TryGetProperty("Ladder", out var l) => $"{l.GetArrayLength()}-rung ladder", + "tdm" when e.TryGetProperty("KillGoal", out var kg) => $"First to {kg.GetInt32()} kills", + _ => "", + }; + } + + // A player's current GG weapon: their rung indexed into the ladder the GG driver ships in Extra. + public static string? RungWeapon(StatusPayload s, HumanRow h) + { + if (s.Mode != "gungame" || s.Extra.ValueKind != JsonValueKind.Object) return null; + if (!s.Extra.TryGetProperty("Ladder", out var l) || l.ValueKind != JsonValueKind.Array) return null; + int n = l.GetArrayLength(); + if (n == 0) return null; + return l[Math.Clamp(h.Rung, 0, n - 1)].GetString(); + } + + // Best-effort display for raw weapon designer names in balance payloads (the site has no engine name table; + // status payloads carry pre-rendered display names, this is only for the guides' config-derived lists). + public static string PrettyWeapon(string w) => + w.StartsWith("weapon_", StringComparison.Ordinal) ? w[7..].Replace('_', ' ').ToUpperInvariant() : w; + + public static int IntOf(JsonElement obj, string prop, int fallback = 0) => + obj.ValueKind == JsonValueKind.Object && obj.TryGetProperty(prop, out var v) && v.TryGetInt32(out int i) ? i : fallback; + + public static double NumOf(JsonElement obj, string prop, double fallback = 0) => + obj.ValueKind == JsonValueKind.Object && obj.TryGetProperty(prop, out var v) && v.ValueKind == JsonValueKind.Number ? v.GetDouble() : fallback; + + public static bool BoolOf(JsonElement obj, string prop, bool fallback = false) => + obj.ValueKind == JsonValueKind.Object && obj.TryGetProperty(prop, out var v) && (v.ValueKind == JsonValueKind.True || v.ValueKind == JsonValueKind.False) ? v.GetBoolean() : fallback; + + public static string StrOf(JsonElement obj, string prop, string fallback = "") => + obj.ValueKind == JsonValueKind.Object && obj.TryGetProperty(prop, out var v) && v.ValueKind == JsonValueKind.String ? v.GetString() ?? fallback : fallback; + + // Survival card Detail strings are FORMAT TEMPLATES ("{0} = level x PerPick" per the card defs) that the in-game + // draft fills at render time. The guide shows the per-pick line, so format with one pick's worth. + public static string CardDetail(string template, double perPick) + { + if (string.IsNullOrEmpty(template)) return ""; + try { return string.Format(System.Globalization.CultureInfo.InvariantCulture, template, perPick); } + catch (FormatException) { return template; } // malformed template -> show raw rather than nothing + } + } +} diff --git a/appsettings.Development.json b/appsettings.Development.json new file mode 100644 index 0000000..4413a08 --- /dev/null +++ b/appsettings.Development.json @@ -0,0 +1,5 @@ +{ + "Outnumbered": { + "SocketDir": "/tmp/og-sock" + } +} diff --git a/appsettings.json b/appsettings.json new file mode 100644 index 0000000..527c803 --- /dev/null +++ b/appsettings.json @@ -0,0 +1,14 @@ +{ + "Urls": "http://127.0.0.1:5080", + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "Outnumbered": { + "SocketDir": "/run/outnumbered", + "PublicHost": "cs2-on.eu", + "ReleasesUrl": "https://git.lo.sh/kamal/cs2-outnumbered/releases" + } +} diff --git a/cs2web.csproj b/cs2web.csproj new file mode 100644 index 0000000..1cd5e35 --- /dev/null +++ b/cs2web.csproj @@ -0,0 +1,10 @@ + + + net10.0 + enable + enable + cs2web + CsWeb + true + + diff --git a/wwwroot/css/site.css b/wwwroot/css/site.css new file mode 100644 index 0000000..e57491a --- /dev/null +++ b/wwwroot/css/site.css @@ -0,0 +1,185 @@ +/* Dark-only, function over form: one small sheet, no framework, no webfonts, no animation. */ +:root { + --bg: #101318; + --panel: #181d24; + --panel2: #1f2630; + --line: #2a323d; + --text: #d7dde4; + --muted: #8b95a1; + --accent: #62c47f; + --accent2: #d9a94a; + --bad: #d06a5f; +} +* { box-sizing: border-box; } +html { color-scheme: dark; } +body { + margin: 0; + background: var(--bg); + color: var(--text); + font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; + /* sticky footer: short pages pin the footer to the viewport bottom instead of hugging the content */ + display: flex; + flex-direction: column; + min-height: 100vh; +} +/* width:100% matters: main/footer are flex items whose auto margins would otherwise cancel stretch (shrink-wrap) */ +/* 1440: the simulator's player-state row needs >=1408 to stay on one line */ +.wrap { width: 100%; max-width: 1440px; margin: 0 auto; padding: 0 16px; } +a { color: var(--accent); text-decoration: none; } +a:hover { text-decoration: underline; } + +header { border-bottom: 1px solid var(--line); background: var(--panel); } +header nav { display: flex; gap: 18px; align-items: center; height: 52px; } +header nav a { color: var(--text); } +header nav a:hover { color: var(--accent); text-decoration: none; } +.brand { font-weight: 700; font-size: 17px; margin-right: 12px; } +.brand span { color: var(--accent); } + +main { flex: 1; padding: 36px 16px 48px; } +footer { + margin-top: auto; + border-top: 1px solid var(--line); + padding: 14px 16px; + color: var(--muted); + font-size: 13px; + display: flex; + justify-content: space-between; + flex-wrap: wrap; + gap: 8px; +} +footer a { color: var(--muted); } + +h1 { font-size: 24px; margin: 0 0 6px; } +h2 { font-size: 18px; margin: 28px 0 10px; } +h3 { font-size: 15px; margin: 18px 0 8px; } +p, li { color: var(--text); max-width: 75ch; } +.muted { color: var(--muted); } +small, .small { font-size: 13px; } + +.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; margin-top: 16px; } +.card { + background: var(--panel); + border: 1px solid var(--line); + border-radius: 8px; + padding: 14px 16px; + display: flex; + flex-direction: column; + gap: 8px; +} +.card h3 { margin: 0; font-size: 16px; } +.card .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; } + +.badge { + display: inline-block; + padding: 1px 8px; + border-radius: 10px; + font-size: 12px; + background: var(--panel2); + border: 1px solid var(--line); + color: var(--muted); + white-space: nowrap; +} +.badge.mode { color: var(--accent); border-color: var(--accent); } +.badge.off { color: var(--bad); border-color: var(--bad); } + +.btn { + display: inline-block; + background: var(--accent); + color: #0c1210; + font-weight: 600; + padding: 6px 14px; + border-radius: 6px; + border: 0; +} +.btn:hover { filter: brightness(1.1); text-decoration: none; } + +code[title] { text-decoration: underline dotted var(--muted); cursor: help; } +code, kbd, .connect { + font-family: ui-monospace, "Cascadia Code", Consolas, monospace; + font-size: 13px; + background: var(--panel2); + border: 1px solid var(--line); + border-radius: 4px; + padding: 1px 6px; +} +.connect { display: inline-block; padding: 5px 10px; user-select: all; } + +table { border-collapse: collapse; width: 100%; margin: 10px 0 20px; } +.tablewrap { overflow-x: auto; } +th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); } +th { color: var(--muted); font-weight: 600; font-size: 13px; } +tr:hover td { background: var(--panel); } +td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; } + +.notice { + background: var(--panel); + border: 1px solid var(--accent2); + border-radius: 8px; + padding: 10px 14px; + color: var(--text); + margin: 12px 0; +} +.notice.err { border-color: var(--bad); } + +.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; } + +/* ---- theory curves (small multiples; recessive grid, 2px series, shared crosshair) ---- */ +figure { margin: 16px 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; } +svg.panel { display: block; width: 100%; height: auto; touch-action: none; } +.panel .grid { stroke: var(--line); stroke-width: 1; } +.panel .grid.one { stroke-dasharray: 4 4; stroke: var(--muted); opacity: 0.6; } +.panel .series { fill: none; stroke-width: 2; stroke-linejoin: round; } +.panel .cross { stroke: var(--text); stroke-width: 1; opacity: 0.45; } +.panel .ptitle { fill: var(--text); font-size: 12px; font-weight: 600; } +.panel .tick { fill: var(--muted); font-size: 11px; text-anchor: end; font-variant-numeric: tabular-nums; } +.panel .tick.mid { text-anchor: middle; } +.readout { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding-bottom: 10px; font-variant-numeric: tabular-nums; } +.readout input[type="range"] { width: 220px; accent-color: var(--accent); vertical-align: middle; } +.readout .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; } +figcaption { text-align: center; padding-top: 6px; } +.panel .simt { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 3 3; } + +/* ---- simulator ---- */ +.sim input[type="number"] { + width: 78px; + background: var(--panel2); + border: 1px solid var(--line); + border-radius: 4px; + color: var(--text); + padding: 3px 6px; + text-align: right; + font-variant-numeric: tabular-nums; +} +.sim input[type="checkbox"] { accent-color: var(--accent); } +.sim fieldset { + border: 1px solid var(--line); + border-radius: 8px; + background: var(--panel); + margin: 0 0 16px; + padding: 10px 14px 14px; +} +.sim legend { color: var(--muted); font-size: 13px; font-weight: 600; padding: 0 6px; } +.sim .fields { display: flex; flex-wrap: wrap; gap: 10px 22px; } +.sim .fields label { display: flex; align-items: center; gap: 8px; font-size: 14px; } +.simout { + display: flex; + flex-wrap: wrap; + gap: 8px 26px; + align-items: baseline; + background: var(--panel); + border: 1px solid var(--accent); + border-radius: 8px; + padding: 10px 14px; + margin: 0 0 16px; + font-variant-numeric: tabular-nums; +} +.simout b { font-size: 18px; } +.simout .lbl { color: var(--muted); font-size: 12px; display: block; } +.sim td input[type="number"] { width: 64px; } +.sim .modified { outline: 1px solid var(--accent2); } + +/* handicap knobs: semantic groups as a grid of boxes; inside each, label|input rows */ +.kgroups { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; } +.kgroup { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px 10px; } +.kgroup h4 { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; } +.kgroup label { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 3px 0; font-size: 14px; } diff --git a/wwwroot/js/theory.js b/wwwroot/js/theory.js new file mode 100644 index 0000000..21e94cf --- /dev/null +++ b/wwwroot/js/theory.js @@ -0,0 +1,272 @@ +// Theory page: live curves + the simulator. Seeded from the server's effective config (#sim-data); every formula +// below MIRRORS the plugin's Domain layer (file noted per function). The VALUES always come from the server payload — +// only the formula shapes are duplicated here, and those change rarely. Abilities/crits/headshots are deliberately +// excluded (parity with the in-game HUD's base readout). +(function () { + "use strict"; + const seedEl = document.getElementById("sim-data"); + if (!seedEl) return; + let seed; + try { seed = JSON.parse(seedEl.textContent); } catch { return; } + if (!seed?.Curves?.T || seed.Curves.T.length < 2) return; + + // Geometry mirrors TheoryModel constants (viewBox units). + const L = 46, R = 10, W = 720, T = 10, PLOTH = 134, PLOT = W - L - R; + const N = seed.Curves.T.length; + + const clamp = function (v, a, b) { return Math.max(a, Math.min(b, v)); }; + const clamp01 = function (v) { return clamp(v, 0, 1); }; + const lerp = function (a, b, t) { return a + (b - a) * t; }; + + // HandicapModel.Ease: sign-preserving curve easing. + function ease(t, curve) { return t >= 0 ? Math.pow(t, curve) : -Math.pow(-t, curve); } + + // HandicapModel.ComputeT + ResolvedHandicap's guard denominators. Returns the RAW post-floor t (the chart's + // x-axis); callers ease it before the band lerps — ease(raw) is exactly what the live ComputeT returns. + function computeRawT(h, p) { + if (!h.Enabled) return 0; + const kdNerfDenom = Math.max(0.01, h.KdMaxNerf - h.KdNeutral); + const kdBuffDenom = Math.max(0.01, h.KdNeutral - h.KdMinBuff); + const hsDenom = Math.max(0.01, h.HsMaxNerf); + const streakDenom = Math.max(1, h.StreakMaxNerf); + const levelDenom = Math.max(1, h.LevelMaxNerf); + const wsum = h.KdWeight + h.HsWeight + h.StreakWeight + h.LevelWeight + h.ProgressWeight; + + let kdN = 0, buff = 0; + if (p.kills + p.deaths >= 3) { + const r = p.kills / Math.max(1, p.deaths); + kdN = clamp01((r - h.KdNeutral) / kdNerfDenom); + buff = clamp01((h.KdNeutral - r) / kdBuffDenom); + } + const hsRate = p.kills >= h.HsMinKills ? p.hsk / Math.max(1, p.kills) : 0; + let n = wsum <= 0 ? 0 : + (h.KdWeight * kdN + h.HsWeight * clamp01(hsRate / hsDenom) + h.StreakWeight * clamp01(p.streak / streakDenom) + + h.LevelWeight * clamp01(p.level / levelDenom) + h.ProgressWeight * clamp01(p.progress)) / wsum; + + let t = clamp(h.MasterDifficulty * (n - buff), -1, 1); + if (p.floor > t) t = Math.min(p.floor, 1); + return t; + } + + // HandicapModel.DealFromT/TakeFromT/XpFromT (takes the EASED t; team multipliers ride on deal/take only). + function bands(eased, h, teamDeal, teamTake) { + return { + deal: (eased >= 0 ? lerp(1, h.MDealFloor, eased) : lerp(1, h.MDealCeiling, -eased)) * teamDeal, + take: (eased >= 0 ? lerp(1, h.MTakeCeiling, eased) : lerp(1, h.MTakeFloor, -eased)) * teamTake, + xp: eased >= 0 ? lerp(1, h.XpCeiling, eased) : lerp(1, h.XpFloor, -eased), + }; + } + + // ---- state ---- + const h = {}; // live handicap knobs (seeded from server) + const player = { level: 0, prestige: 0, kills: 0, deaths: 0, hsk: 0, streak: 0, progress: 0, floor: -1, prestigeBoost: seed.PrestigeBoostPercent }; + const invested = {}; // stat key -> levels + const cards = {}; // card key -> picks + const statDefs = {}; // key -> {Base, PerLevel} + seed.Stats.forEach(function (s) { statDefs[s.Key] = s; invested[s.Key] = 0; }); + seed.Cards.forEach(function (c) { cards[c.Key] = 0; }); + const curves = { deal: [], take: [], xp: [] }; // resampled from live knobs + + // StatResolver.Eff + EffRun: base + invested*perLevel (+ stat-keyed card picks x PerPick — card key == stat key). + function effRun(key) { + const d = statDefs[key]; + let v = d ? d.Base + (invested[key] || 0) * d.PerLevel : 0; + const card = seed.Cards.find(function (c) { return c.Key === key && !c.IsTeam; }); + if (card) v += (cards[key] || 0) * card.PerPick; + return v; + } + + // SurvivalDriver team cards: compounding per shared squad level ((1±PerPick/100)^picks). + function teamMults() { + let deal = 1, take = 1; + seed.Cards.forEach(function (c) { + if (!c.IsTeam) return; + if (c.Key === "global_deal") deal = Math.pow(1 + c.PerPick / 100, cards[c.Key] || 0); + if (c.Key === "global_take") take = Math.pow(1 - c.PerPick / 100, cards[c.Key] || 0); + }); + return { deal: deal, take: take }; + } + + // ---- curves: resample the 201 points from the LIVE knobs (HandicapModel.BandsFromT + Api.cs's loop, client-side; + // the disabled short-circuit mirrors BandsFromT's own) ---- + function resample() { + curves.deal = []; curves.take = []; curves.xp = []; + for (let i = 0; i < N; i++) { + const t = -1 + i * (2 / (N - 1)); + let b = bands(ease(clamp(t, -1, 1), h.Curve), h, 1, 1); + if (!h.Enabled) b = { deal: 1, take: 1, xp: 1 }; + curves.deal.push(b.deal); curves.take.push(b.take); curves.xp.push(b.xp); + } + } + + function yScale(vals) { // TheoryModel.BuildPanel's ymax rule + const max = Math.max.apply(null, vals); + const step = max <= 2 ? 0.5 : max <= 5 ? 1 : 2; + return Math.max(step, Math.ceil(max / step) * step); + } + + function redrawPanels() { + panels.forEach(function (svg) { + const vals = curves[svg.dataset.key]; + const ymax = yScale(vals); + const pts = []; + for (let i = 0; i < vals.length; i++) { + const x = L + i / (vals.length - 1) * PLOT; + const y = T + PLOTH * (1 - vals[i] / ymax); + pts.push(x.toFixed(1) + "," + y.toFixed(1)); + } + svg.querySelector(".series").setAttribute("points", pts.join(" ")); + const oneY = T + PLOTH * (1 - 1 / ymax); + const one = svg.querySelector(".grid.one"); + one.setAttribute("y1", oneY); one.setAttribute("y2", oneY); + const ymaxLbl = svg.querySelector(".tick.ymax"); + ymaxLbl.textContent = (Math.round(ymax * 10) / 10).toString(); + svg.querySelectorAll(".tick").forEach(function (tk) { + if (tk.textContent === "×1") tk.setAttribute("y", oneY + 4); + }); + svg._ymax = ymax; + }); + } + + // ---- readouts ---- + const $ = function (id) { return document.getElementById(id); }; + const panels = Array.prototype.slice.call(document.querySelectorAll("svg.panel")); + const slider = $("tslider"); + + function fmt(v) { return "×" + v.toFixed(2); } + + function recompute() { + resample(); + redrawPanels(); + + const rawT = computeRawT(h, player); + const tm = teamMults(); + let b = bands(ease(rawT, h.Curve), h, tm.deal, tm.take); + if (!h.Enabled) b = { deal: tm.deal, take: tm.take, xp: 1 }; + + $("sim-t").textContent = rawT.toFixed(2); + $("sim-deal").textContent = fmt(b.deal); + $("sim-take").textContent = fmt(b.take); + $("sim-xpband").textContent = fmt(b.xp); + // Hud.EffectiveMultipliers parity (headshot:false, crit:false, no actives): + $("sim-out").textContent = fmt((1 + effRun("damage") / 100) * b.deal); + $("sim-in").textContent = fmt(b.take); + $("sim-hs").textContent = fmt(1 + effRun("hs_damage") / 100); + // ProgressionModel.PrestigeXpMultiplier: 1 + prestige * boost%/100. + $("sim-xp").textContent = fmt((1 + effRun("xp_boost") / 100) * (1 + player.prestige * (player.prestigeBoost / 100)) * b.xp); + + // effective column per stat + seed.Stats.forEach(function (s) { + const el = $("eff-" + s.Key); + if (el) el.textContent = (Math.round(effRun(s.Key) * 100) / 100).toString(); + }); + + // the simulated player's position on the raw-t axis + const x = L + (rawT + 1) / 2 * PLOT; + panels.forEach(function (svg) { + const m = svg.querySelector(".simt"); + m.setAttribute("x1", x); m.setAttribute("x2", x); + }); + updateCross(Number.parseFloat(slider.value)); + } + + // ---- slider / hover crosshair (explores the CURRENT — possibly edited — curves) ---- + function updateCross(t) { + t = clamp(t, -1, 1); + const i = Math.round((t + 1) / 2 * (N - 1)); + $("tval").textContent = "t = " + t.toFixed(2); + const x = L + (t + 1) / 2 * PLOT; + panels.forEach(function (svg) { + const cross = svg.querySelector(".cross"); + cross.setAttribute("x1", x); cross.setAttribute("x2", x); + const ro = $("ro-" + svg.dataset.key); + if (ro) ro.textContent = fmt(curves[svg.dataset.key][i]); + }); + } + + slider.addEventListener("input", function () { updateCross(Number.parseFloat(slider.value)); }); + panels.forEach(function (svg) { + svg.addEventListener("pointermove", function (ev) { + const rect = svg.getBoundingClientRect(); + const vx = (ev.clientX - rect.left) * (W / rect.width); + let t = ((vx - L) / PLOT) * 2 - 1; + slider.value = t.toFixed(2); + updateCross(t); + }); + }); + + // ---- input wiring + seeding ---- + function seedInputs() { + Object.keys(seed.Handicap).forEach(function (k) { h[k] = seed.Handicap[k]; }); + h.Enabled = !!h.Enabled; + document.querySelectorAll("[data-h]").forEach(function (el) { + const k = el.dataset.h; + if (el.type === "checkbox") el.checked = !!seed.Handicap[k]; + else el.value = seed.Handicap[k]; + el.classList.remove("modified"); + }); + document.querySelectorAll("[data-sim]").forEach(function (el) { + const k = el.dataset.sim; + player[k] = k === "floor" ? -1 : k === "prestigeBoost" ? seed.PrestigeBoostPercent : 0; + el.value = player[k]; + el.classList.remove("modified"); + }); + document.querySelectorAll("[data-stat]").forEach(function (el) { invested[el.dataset.stat] = 0; el.value = 0; el.classList.remove("modified"); }); + document.querySelectorAll("[data-card]").forEach(function (el) { cards[el.dataset.card] = 0; el.value = 0; el.classList.remove("modified"); }); + } + + function markModified(el, isDefault) { el.classList.toggle("modified", !isDefault); } + + // Out-of-range typed values are clamped AND written back to the field, so the display always shows the number the + // sim actually used (silent clamping in a theorycrafting tool is a lie). Partial input ("", "-") is left alone. + function clampedInt(el) { + const raw = Number.parseInt(el.value, 10); + const v = clamp(Number.isNaN(raw) ? 0 : raw, 0, Number.parseInt(el.max, 10) || 0); + if (!Number.isNaN(raw) && raw !== v) el.value = v; + return v; + } + + document.querySelectorAll("[data-h]").forEach(function (el) { + el.addEventListener("input", function () { + const k = el.dataset.h; + if (el.type === "checkbox") { h[k] = el.checked; markModified(el, el.checked === !!seed.Handicap[k]); } + else { + let v = Number.parseFloat(el.value) || 0; + // The plugin defines Curve's valid domain as > 0 (Pow(0, negative) = Infinity would NaN the charts); + // mirror that boundary here — the payload can never seed a bad value, only an edit can. + if (k === "Curve") v = Math.max(v, 0.05); + h[k] = v; + markModified(el, v === seed.Handicap[k]); + } + recompute(); + }); + }); + document.querySelectorAll("[data-sim]").forEach(function (el) { + el.addEventListener("input", function () { + const k = el.dataset.sim; + const dflt = k === "floor" ? -1 : k === "prestigeBoost" ? seed.PrestigeBoostPercent : 0; + const v = Number.parseFloat(el.value); + player[k] = Number.isFinite(v) ? v : dflt; // a cleared field means "default", not 0 (floor 0 is an ACTIVE floor) + markModified(el, player[k] === dflt); + recompute(); + }); + }); + document.querySelectorAll("[data-stat]").forEach(function (el) { + el.addEventListener("input", function () { + invested[el.dataset.stat] = clampedInt(el); + markModified(el, invested[el.dataset.stat] === 0); + recompute(); + }); + }); + document.querySelectorAll("[data-card]").forEach(function (el) { + el.addEventListener("input", function () { + cards[el.dataset.card] = clampedInt(el); + markModified(el, cards[el.dataset.card] === 0); + recompute(); + }); + }); + $("sim-reset").addEventListener("click", function () { seedInputs(); recompute(); }); + + seedInputs(); + recompute(); +})();