3 Replies - 372 Views - Last Post: 09 August 2011 - 09:56 PM Rate Topic: -----

#1 dangmnx  Icon User is offline

  • D.I.C Regular

Reputation: -1
  • View blog
  • Posts: 428
  • Joined: 10-April 09

Ranking system

Posted 09 August 2011 - 03:15 AM

So here is my ranking system. I want to leave everything the same except When a person reaches

Quote

A1, A2, A3, S
ranks, It will be much harder to receive points. For instance. Right now

Quote

D vs D
winner gets +65 and losers gets -65. I want to make it to where when

Quote

S rank vs S
rank, it will be like -75 +75.... and so forth.

// D vs D rank
if ($difference == 0){
$points = $points + 65;
$points1 = $points1 - 30;
}

// C3 vs D rank
else if($difference == 1){
$points = $points + 56;
$points1 = $points1 -27;
}

// C2 vs D rank
else if ($difference == 2){
$points = $points + 49;
$points1 = $points1 -24;
}

// C1 vs D rank
else if($difference == 3){
$points = $points + 43;
$points1 = $points1 -19;
}

// B3 vs D rank
else if ($difference == 4){
$points = $points + 36;
$points1 = $points1 -16;
}

// B2 vs D rank
else if($difference == 5){
$points = $points + 29;
$points1 = $points1 -12;
}

// B1 vs D rank
else if ($difference == 6){
$points = $points + 22;
$points1 = $points1 -9;
}
     
// A3 vs D rank
else if($difference == 7){
$points = $points + 15;
$points1 = $points1 -6;
}

// A2 vs D rank
else if ($difference == 8){
$points = $points + 9;
$points1 = $points1 -3;
}

// A1 vs D rank
else if($difference == 9){
$points = $points + 4;
$points1 = $points1 -2;
}

// S vs D rank
else{
$points = $points + 1;
$points1 = $points1 -1;
}
}
	
else{
//opp_rank > $user_rank
$difference = $opp_rank - $user_rank;

// D vs D rank		
if ($difference == 0){
$points = $points + 65;
$points1 = $points1 - 30;
}

// D vs C3 rank
else if($difference == 1){
$points = $points + 74;
$points1 = $points1 -37;
}

// D vs C2 rank
else if ($difference == 2){
$points = $points + 83;
$points1 = $points1 -46;
}

// D vs C1 rank
else if($difference == 3){
$points = $points + 91;
$points1 = $points1 -55;
}

// D vs B3 rank
else if ($difference == 4){
$points = $points + 102;
$points1 = $points1 -65;
}

// D vs B2 rank
else if($difference == 5){
$points = $points + 114;
$points1 = $points1 -73;
}

// D vs B1 rank
else if ($difference == 6){
$points = $points + 123;
$points1 = $points1 -79;
}

// D vs A3 rank
else if($difference == 7){
$points = $points + 138;
$points1 = $points1 -93;
}

// D vs A2 rank
else if ($difference == 8){
$points = $points + 152;
$points1 = $points1 -101;
}

// D vs A1 rank
else if($difference == 9){
$points = $points + 164;
$points1 = $points1 -115;
}

// D vs S rank
else{
$points = $points + 180;
$points1 = $points1 -130;
}



Here's the ranks array
$rank = array(
'D' => 0,
'C3' =>1,
'C2' =>2,
'C1' =>3,
'B3' =>4,
'B2' =>5,
'B1' =>6,
'A3' =>7,
'A2' =>8,
'A1' =>9,
'S' =>10);

This post has been edited by dangmnx: 09 August 2011 - 03:16 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Ranking system

#2 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1001
  • View blog
  • Posts: 3,555
  • Joined: 05-June 09

Re: Ranking system

Posted 09 August 2011 - 03:22 AM

I take it you just want us to tidy up your code so that it's a lot more readable, right?

I really think that you should just be defining the modifiers for each "rank" when they're fighting each other and add them together. That would make more sense in the long run, so if S had a modifier of 30, and it was fighting another S, the battle would have a positive/negative outcome of 60 for both parties.

When it comes to D (modifier of 5) vs S (modifier of 30).. The outcome would be -35/+35, you see what I mean?

I mean let's face it if a D kills an S, I suppose that's impossible, so they deserve all the points :)

Does that make sense?? Sorry to be kindof changing your ranking system but it would make your code so much easier to maintain.
Was This Post Helpful? 2
  • +
  • -

#3 dangmnx  Icon User is offline

  • D.I.C Regular

Reputation: -1
  • View blog
  • Posts: 428
  • Joined: 10-April 09

Re: Ranking system

Posted 09 August 2011 - 01:26 PM

Okay So is it possible for me to just go back and simplify one part of the code? I want to simply
S rank vs S rank
. and winner gets
+75 loser get -100.


Sort of like:
// S vs S rank
if ($difference == 10){
$points = $points + 75;
$points1 = $points1 - 100;
}


But I'm afraid the

// D vs D rank
if ($difference == 0){
$points = $points + 65;
$points1 = $points1 - 30;
}


Won't allow me to do that.
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10180
  • View blog
  • Posts: 37,586
  • Joined: 27-December 08

Re: Ranking system

Posted 09 August 2011 - 09:56 PM

I don't understand what the problem is. What does one if statement have to do with the other? Also, what formula are you using to generate your numbers? They seem a little random to me. A more formulaic approach will help you simplify your code greatly.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1