Core System Design and Implementation for a Multi-Civilization War Strategy Web Game

    This article explains how to architect a large-scale, multi-civilization war strategy web game. It covers the design goals behind "numbers-heavy, planning-heavy, low-interaction" gameplay; two-level world map modeling that decouples geography from scenario scripts; a configuration-driven class, unit, and counter system supporting hundreds of unit types; a semi-real-time turn-based battle engine with deterministic logic; a task and dungeon pipeline built on state machines and reward pools; automation features such as idle teaming, dungeon sweeping, and auto tournament participation; and a building system organized as a directed acyclic dependency graph. It concludes with three engineering principles: configuration-driven content, layered system decoupling, and automation-first design.

    Background and Overall Design Goals

    The defining characteristics of war strategy web games are “heavy on numbers, heavy on planning, and light on interaction.” Taking a comparable product developed independently over several years as an example, its design goals can be summarized on three levels:

    1. Sufficient content scale: A sandbox covering the six continents of the world, spanning multiple civilization eras and blending eight major mythologies, with more than 190 buildings and over 360 unit types, providing content depth for long-term live operations.
    2. Sufficient strategic depth: Multiple intertwined progression lines—city building, technology research, unit hiring, magic skills—give players a decision space far larger than single-threaded level-push gameplay.
    3. Low interaction barrier: Automated operations and batch features reduce repetitive labor, shifting player attention from “clicking” to “planning.”

    In engineering terms, these translate to three key problems: configuration-driven content, a layered numerical system, and automated task pipelines.

    Modeling the World Map and Multi-Civilization Sandbox

    The map is the spatial backbone of every other system. Games in this genre typically use a two-level “world map + city nodes” structure: the world map is divided into continental regions such as Eurasia, the Americas, Africa, and Oceania, and each continent hosts a number of city nodes. Cities form gameplay relationships through attributes like march time, faction ownership, and resource production.

    For data modeling, decouple geography from gameplay:

    • The geography layer stores only static data (continents, city coordinates, ownership).
    • The gameplay layer maps scenario elements such as civilization eras and mythological backgrounds onto geographic nodes via configuration tables.

    This way, when operations need to add a new civilization era or adjust the script, only configuration changes are required—no map service code needs touching. This is the foundational engineering approach that supports content on the scale of “six civilization eras.”

    Classes and Units: A Configuration-Driven System

    The game defines four classes—Warrior, Sage, Wise One, and Sovereign—each excelling with different unit types (vanguard, ranged, support, and infantry, respectively), with the Sovereign being well balanced. The essence of this design is a three-layer configuration system of “class → unit type → counter relationships”:

    • Class layer: defines growth curves, equipable unit preferences, and skill weights.
    • Unit layer: defines base attributes (attack, defense, speed, cost, upkeep).
    • Counter layer: defines the affinity matrix between unit types, ensuring battle outcomes are not pure stat碾压 but genuine counters.

    Hard-coding 360+ unit types would make maintenance costs uncontrollable. The recommended approach is to abstract each unit into a uniform attribute structure, for example:

    1. {
    2. "unit_id": "archer_t3",
    3. "class_affinity": "sage",
    4. "base_attr": {"atk": 85, "def": 42, "speed": 90},
    5. "counter": {"cavalry": 1.25, "infantry": 0.85},
    6. "cost": {"silver": 300, "food": 120}
    7. }

    The battle calculation module reads only this configuration, so adding or rebalancing units requires no changes to the battle engine code.

    Implementing the Semi-Real-Time Turn-Based Combat System

    Combat is the heart of the player experience. In semi-real-time turn-based combat, the overall flow advances turn by turn, but time slices or an action-order timeline within each turn blend strategy with pacing. The system needs to support two modes:

    • Hero mode: only the hero fights, used for special scenarios (high-difficulty challenges, story battles), emphasizing deep use of single-target skills.
    • Sovereign mode: a regular army fights—the mainstream mode for resource wars and PvP, emphasizing overall unit composition and counters.

    The combat loop can be expressed in pseudocode:

    1. def battle_loop(units, mode):
    2. timeline = init_action_order(units)
    3. while not battle_end(units):
    4. actor = timeline.next()
    5. # Prefer behavior determined by the player's configured skill strategy
    6. skill = choose_skill(actor, mode)
    7. if skill and skill.ready():
    8. cast_skill(actor, skill)
    9. else:
    10. # Fall back to equipped magic or a normal attack
    11. cast_magic_or_attack(actor)
    12. timeline.advance()
    13. return settle_rewards(units)

    Skills and magic are two parallel progression lines: skills are gained by leveling up the lord and spending skill points in the skill interface; magic is mounted onto combat units as equipment items, with each magic producing different battle effects, and upgrading magic increases its power. In implementation, model “skills” as passive/active stat modifiers and “magic” as swappable battle effect instances, both resolved through a unified effect computation pipeline to avoid coupling.

    Task and Dungeon Pipelines

    The task system serves both onboarding and content distribution. Typical patterns in this genre include:

    1. Main quests are delivered by an assistant-style guidance component interleaved with story introductions, helping players learn each feature and grow quickly.
    2. Other tasks are grouped by theme—governance, military, culture—with most completed in dungeon form.
    3. Adventurer guild-type buildings provide daily task entries, a major source of experience: up to 20 pickups per day, with tasks tiered by quality, and higher quality yielding better rewards.

    In engineering terms, a task is a state machine of “trigger condition → completion check → reward grant.” Quality-to-reward mapping should be implemented as a reward pool configuration:

    1. def grant_daily_task_reward(player, task):
    2. pool = reward_pools[task.quality] # index reward pool by quality
    3. reward = weighted_draw(pool)
    4. player.inventory.add(reward)
    5. log_event("task_reward", player.id, task.id, reward)

    PvE content consists of historical campaign map progression and tower-style dungeons: the former provides narrative momentum, the latter provides quantified difficulty challenges. Both share a single dungeon settlement framework, differing only in how level data is organized.

    Automation and Batch Operations: The Key to Lowering the Barrier

    Automation is the most distinctive design element of this genre, including idle team formation, dungeon sweeping, and automatic participation in arenas and tournaments. From an engineering perspective, automation means solidifying repetitive player decisions into configurable strategies:

    • Idle team formation: automatically match dungeon teams with a preset lineup, letting players accumulate rewards even while offline.
    • Dungeon sweeping: for dungeons already cleared with three stars, skip the battle process and settle directly. This depends on battle results being reproducible—battle logic must therefore be deterministic, with random factors kept consistent via seeded replay.
    • Auto participation: arenas and tournaments automatically match opponents and settle rankings per the rules; the server must handle scheduling and result consistency for high-concurrency matches.

    PvP competition is built on two scenarios: the arena for day-to-day combat and the tournament for periodic honor goals. Both can reuse the same matching and settlement services with different competition parameters.

    The Building System and the Resource Hub

    City buildings serve as entry points to all system features. The city hall plays a dual role as the most critical building: it produces resources (silver) and acts as the single management path for upgrading and reconfiguring other buildings. This “hub building” design means, technically, that buildings form a dependency topology—the upgrade tree should be modeled as a directed acyclic graph, with prerequisites validated before any state change, to prevent illegal upgrades that bypass dependencies.

    Summary

    Looking back at the implementation of this type of multi-civilization strategy web game, its success factors distill into three engineering principles:

    1. Configuration-driven content: data-driven design supports hundreds of buildings and unit types.
    2. Layered system decoupling: combat, tasks, buildings, and competitions collaborate through unified effect and settlement pipelines.
    3. Automation first: repetitive operations are abstracted into player-configurable strategies, using engineering means to deliver the “planning-heavy, interaction-light” design philosophy.

    For teams planning to build a similar product, the lowest-risk evolution path is to first establish the configuration system and a deterministic combat kernel, then progressively layer on automation and competitive gameplay.