npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@civ-clone/base-diplomacy

v0.1.3

Published

Baseline diplomacy a ruleset builds its rules from: contact, standing, war and peace, a computer player's stance and the steps of a meeting, with the ruleset's own numbers.

Readme

base-diplomacy

Baseline diplomacy a ruleset builds its rules from: contact, standing, war and peace, a computer player's stance at a meeting and the steps of the meeting itself. Each is a plain function, and the ruleset passes in its own content (who is a person, which units are nuclear, its leaders' tempers, which governments answer to a senate, the difficulty level) and its own numbers, so it keeps its own rule ids, numbers and registration:

  • lib/Dependencies: the registries the functions read. playerWorldRegistry is optional: only shareMaps needs it.

  • lib/Readers: what the ruleset tells them about its content.

  • lib/standing: presence, landMassesOf, presenceOn, power, unitCount, gold, cityCount, atPeace, haveMet, atWar, traitScore, governedBy, rankFromTop and rankedFirst.

  • lib/treatyLevel: treatyLevel(dependencies, player, other), how far the pair's treaties go (TreatyLevel: war < contact < ceasefire < peace < alliance); hasTreatyLevel(dependencies, player, other, level), whether they reach level, which stops looking once they do; and treatyName. atPeace is hasTreatyLevel(..., TreatyLevel.Peace): ask these rather than looking for a Peace, so ceasefires and alliances count. War and contact differ only for rule sets that make ceasefires (makeCeasefire ends the war). atWar is met with no treaty, a ceasefire counting as one; Civ1 has none, so for it that is met with no peace, as before.

  • lib/contact: contactOnMove(interactionRegistry, unitRegistry), the criteria and effect of a Moved rule that makes contact between players whose units meet.

  • lib/declareWar: declareWar(dependencies, player, other, forced?), which ends every treaty between them and tells the DeclaredWar rules (Rules/DeclaredWar: (by, against, forced, broken), broken the TreatyLevel just before) whether player was made to declare it; makePeace (which ends a ceasefire), makeCeasefire, makeAlliance (an Alliance beside a Peace, so the pair stays at peace when cancelAlliance ends it; cancelAlliance with no alliance does nothing) and activeDeclarations.

  • lib/embassy: hasEmbassy(dependencies, player, other), one way: an Embassy player holds with other, or any HasEmbassy rule (Rules/HasEmbassy) answering true, as a wonder that acts as an embassy with everyone would.

  • lib/patience: patience(dependencies, holder, toward), with spent(), spend(amount?) and reset(): how much of a computer player's patience with another is used up, kept between meetings.

  • lib/lastContact: lastContact(dependencies, player, other) and recordContact(dependencies, player, other, turn): the turn the pair were last in contact.

  • lib/shareMaps: shareMaps({ playerWorldRegistry }, player, other), each comes to know every square the other knows (and so what's on it: improvements and cities).

  • lib/personMeeting: pieces for a meeting a person opens (Negotiation#initiator()), as MeetingStep rows: audience, proposalMenu (every proposal the ruleset makes that the ProposalAvailable rules allow, then leaving), computerAnswer (from the ruleset's answer), patienceEnds, all of them in personMeetingSteps; and spendPatienceRules, an Interaction rule spending the computer player's patience with each proposal. Every row applies only when a person opened the negotiation, so a meeting a computer player opens (meetingSteps) is untouched; meetingFor works a meeting out from the first player's side, so don't ask it for these.

  • lib/shamPeace: dropShamPeace(dependencies, player, random, chance), for a TurnStart rule.

  • lib/stance: stance(dependencies, readers, numbers, player, other, random?, changeGovernment?), how a computer player comes to a meeting, with StanceNumbers.

  • lib/wouldGoToWar: wouldGoToWar(dependencies, readers, threshold, player, other), whether two computer players meeting go to war.

  • lib/meeting: meetingFor(dependencies, rules, negotiation, random), the meeting worked out once per negotiation, knownMeeting, negotiationOf and calm.

  • lib/meetingSteps: meetingSteps(dependencies, rules, numbers), the meeting's steps in order, each a criterion and what comes next, for the ruleset to make Step rules of. Given rules.isHuman, no row applies to a meeting a person opened (lib/personLed), so a ruleset can register these beside personMeetingSteps.

  • lib/knowledge: advancesLacked and give.

  • lib/exchanged: recordTaken and takenBy, what each player took in an exchange of knowledge.

  • Records/PatienceRecord and Records/LastContactRecord: the saved records behind patience and lastContact, RelationRecords in the InteractionRegistry, made only when a ruleset first writes one. Saves name them by class name, so a game that uses them registers them as saveable classes.

  • Dialogues/AdvanceTaken: the Dialogue in which a player says which advance it took in an exchange of knowledge (key exchange-knowledge.taken). Saves name it by its class name, so a game registers it as a saveable class.

  • lib/rules/*: rule assemblers, which build a ruleset's rules with its own id prefix (<prefix>:...) and numbers, rule for rule as civ1-diplomacy's: expiredRules, interactionRules, stepRules, mayNegotiateRules (with MeetingSpacing), turnStartRules, resolvedRules, detonatedRules and movedRules.

A library: it registers no rules. See civ1-diplomacy for Civilization's.