Introducing the Lucky Wheel in Init Manga v1.6.8

The 1.6.8 release of Init Manga ships a brand-new engagement module — Lucky Wheel, a daily spin feature that rewards readers with EXP, Coin, and Cash. The entire flow is securely handled on the server for fairness and anti-cheating, while the UI is built natively with UIkit for a smooth, modern experience.

Introducing the Lucky Wheel in Init Manga v1.6.8

Visual Interface & Realistic Spin Effects

  • Features a clear 6-wedge design, each color representing a distinct reward tier.
  • Physics-based rotation animation with easing – the wheel always stops exactly at the server-determined winning segment.
  • Integrated Legend displaying reward descriptions for each wedge color – without revealing actual odds.
  • The SPIN button includes tooltips and real-time state feedback when pressed.

Rewards & Weighted Probability

  • Rewards are calculated server-side using a weighted random algorithm, with customizable precision via the init_manga_lw_weight_scale filter.
  • Default probability: 90% no reward, 5% low EXP, 3% medium Coin, 1.5% high Coin, 0.5% rare Cash, and 0% special reward.
  • Supports combined rewards of EXP, Coin, and Cash.
  • When a user wins, the system automatically updates balances and logs all transactions.
  • No probability data is ever exposed to the frontend — the client only receives display values for animation and visual rendering.

AI Balancing System

  • AI Balancing System (New Option): an intelligent AI-driven mechanism that analyzes each player’s spin history and spending behavior to dynamically balance reward probabilities.
  • Frequent big winners will see slightly reduced odds for major prizes, while unlucky players receive minor “consolation boosts” to maintain engagement and fairness.
  • The AI ensures the system never operates at a loss while preserving the natural weighted-random feel of each spin.
  • Can be toggled via the init_manga_lw_ai_assist option; when enabled, all spins are logged into the init_lw_history table for intelligent analysis and future adjustments.

Limits, Cooldown & Security

  • Anti-spam protection with a cooldown system (default: 5 seconds) powered by transients.
  • Daily spin limits are configurable through the init_manga_lw_daily_limit filter. A value ≤ 0 disables daily tracking completely.
  • Strict REST API validation: requires login, verifies X-WP-Nonce, checks Coin/Cash balance, and safely rolls back failed transactions.
  • If the spin price is set to 0, the system automatically disables the feature and returns a clear message to the user.

Smart State System

  • Instead of using the native disabled attribute, the SPIN button uses a .is-disabled class to keep tooltips and login logic active.
  • The spinning state is represented by aria-busy and .is-busy for smooth UX and better accessibility.
  • Clicking a disabled button displays a friendly message through UIkit’s tooltip or toast component.

Leaderboard & Winner Tracking

  • Each successful win increases the user meta counter init_lw_total_wins for leaderboard display.
  • The helper function init_manga_lw_get_top_winners() returns the top players list with: ID, display_name, user_registered, wins.
  • Includes built-in caching for database efficiency, with optional filters by role or excluded user IDs.

High-Security REST API Integration

  • POST /wp-json/initmanga/v1/lucky-wheel/spin — the single endpoint that handles all spin logic, balance deductions, rewards, logging, and response data.
  • All calculations are performed entirely on the server. The frontend only receives the final degree (deg) and reward label.
  • Fully integrated with the Init Manga Inbox and toast notification systems for user feedback.

Developer Filters

  • init_manga_lw_weight_scale: adjusts internal precision for weighted randomization (default 1000).
  • init_manga_lw_daily_limit: sets the maximum number of spins per day; ≤ 0 disables tracking.
  • init_manga_lw_spin_price: modifies the spin cost in Coin.
  • init_manga_lw_mutate_reward: allows custom reward mutation (EXP/Coin/Cash) before applying — ideal for weekend EXP boosts, VIP bonuses, or reward caps.

Example: Weekend Double EXP + VIP Bonus + Cash Cap

add_filter('init_manga_lw_mutate_reward', function ($reward, $ctx) {
    $exp  = max(0, (int) ($reward['exp']  ?? 0));
    $coin = max(0, (int) ($reward['coin'] ?? 0));
    $cash = max(0, (int) ($reward['cash'] ?? 0));
    $user_id = (int) ($ctx['user_id'] ?? 0);

    // Double EXP on Saturday & Sunday
    $wday = (int) wp_date('w', strtotime(($ctx['time_gmt'] ?? gmdate('Y-m-d H:i:s')) . ' UTC'));
    if ($wday === 0 || $wday === 6) {
        $exp *= 2;
    }

    // VIP Bonus: +100 Coin if user meta is_vip = 1
    if ($user_id && init_plugin_suite_user_engine_is_vip($user_id)) {
        $coin += 100;
    }

    // Cap maximum Cash reward to 500 per spin
    $cash = min($cash, 500);

    return [
        'chance' => (float) ($reward['chance'] ?? 0),
        'exp'    => $exp,
        'coin'   => $coin,
        'cash'   => $cash,
    ];
}, 10, 2);

Getting Started

  • Add the template template-lucky-wheel.php and enqueue its related CSS/JS files.
  • Set the spin cost using the init_manga_lw_spin_price filter (set to 0 to disable the feature).
  • Configure rewards and probabilities via theme options or filters; the system never exposes raw odds to the client.
  • Display the leaderboard anywhere using init_manga_lw_get_top_winners() along with built-in user card layouts.

Comments


  • No comments yet.

Init Toolbox

Press Ctrl + \ on desktop, or swipe left anywhere on mobile.

Login