Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8585503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:04:56+00:00 2026-06-11T22:04:56+00:00

I am writing simple drop formula for player A vs. B fights – level

  • 0

I am writing simple drop formula for player A vs. B fights – level difference determinates drop rate. My issue here is that instead of 0: > 10 ||| 1 vs. 1 = 10% it gives 0: > 10 ||| 1 vs. 1 = 0% – why?

PhpFiddle: http://www.phpfiddle.org/main/code/n1q-dw7

<?php

# lets simulate high level player A attacks low level player B
for ($A = 1; $A <= 100; $A++) {
    $B = 1;
    calculateMoneyDrop($A,$B);
}

# lets simulate low level player A attacks high level player B
for ($B = 1; $B <= 100; $B++) {
    $A = 1;
    calculateMoneyDrop($A,$B);
}

function calculateMoneyDrop($A,$B) {
    $X = $A - $B;
    echo '<strong>', $X, '</strong>: ';

    switch ($X) {
        case $X > 10:
            echo "> 10 ||| ";
            $X = 10;
            break;
        case $X < -90:
            echo "< -90 ||| ";
            $X = -90;
            break;
    }

    $dropRate = 10 - $X;
    echo $A, ' vs. ', $B, ' = ', $dropRate, '%<br>';

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:04:57+00:00Added an answer on June 11, 2026 at 10:04 pm

    Well, in your $X > 10 case you set $X = 10 and later calculate $dropRate as 10 - $X, which is 10 - 10, which is 0.

    Either the $dropRate should be $X if the desired outcome is 10. It also strikes me funny that the output says $X == 0 first, but then enters the switch case $X > 10… Are you sure that you’re showing us all the code?

    Also I don’t think it’s good practice to use the switch case like that. This is a typical candidate for an if block.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing my own simple drop-down...and it's not going so well. I need only
I am writing simple site that requires users and profiles to be handled. The
I'm writing a simple MySQL stored procedure: DELIMITER $ DROP PROCEDURE IF EXISTS GetUserByCaseId
Assume that you are writing a simple app. The model is that a 'project'
I'm writing a simple Rails model called Person that has_many :phone_numbers and I'm trying
I'm writing a web application, that requires a drag and drop functionality. The draggable
I am writing a simple multi-drop RS485 protocol for serial communications within a distributed
Im writing a simple jquery menu system that shows / hides a DIV on
I am writing simple parallel program in C++ using OpenMP. I am working on
I'm writing simple program to communicate between smart devices and I receive 11001 when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.