Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
Convert c# to php
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="sami37" data-source="post: 385194" data-attributes="member: 71475"><p>Thanks for reply,</p><p></p><p>Here is the fully program</p><p></p><p>[CODE]using System;</p><p>using System.Collections.Generic;</p><p></p><p>namespace ConsoleApplication1</p><p>{</p><p> class Program</p><p> {</p><p> private const byte ShieldDurabilitySlot = 0,</p><p> ShieldPhySpecSlot = 1,</p><p> ShieldMagSpecSlot = 2,</p><p> ShieldBlockRatioSlot = 3,</p><p> ShieldPhyDefSlot = 4,</p><p> ShieldMagDefSlot = 5;</p><p></p><p> private const byte ArmorDurabilitySlot = 0,</p><p> ArmorPhySpecSlot = 1,</p><p> ArmorMagSpecSlot = 2,</p><p> ArmorPhyDefSlot = 3,</p><p> ArmorMagDefSlot = 4,</p><p> ArmorEvasionRatioSlot = 5;</p><p></p><p> private const byte WeaponDurabilitySlot = 0,</p><p> WeaponPhySpecSlot = 1,</p><p> WeaponMagSpecSlot = 2,</p><p> WeaponHitRatioSlot = 3,</p><p> WeaponPhyDmgSlot = 4,</p><p> WeaponMagDmgSlot = 5,</p><p> WeaponCritSlot = 6;</p><p></p><p> private const byte AccessoryPhyAbsorpSlot = 0,</p><p> AccessoryMagAbsorpSlot = 1;</p><p></p><p> static void Main()</p><p> {</p><p> const ulong variance = 20401094656;</p><p> DisplayVariance(variance);</p><p></p><p> Console.ReadLine();</p><p> }</p><p></p><p> static void DisplayVariance(ulong variance)</p><p> {</p><p> var stats = new List<byte>();</p><p></p><p> Console.WriteLine("Variance : " + variance);</p><p> while (variance > 0)</p><p> {</p><p> var stat = (byte)(variance & 0x1f);</p><p> variance >>= 5;</p><p></p><p> stats.Add(stat);</p><p> }</p><p> switch (stats.Count)</p><p> {</p><p> case 2:</p><p> //Accessory</p><p> Console.WriteLine("Accessory : AccessoryPhyAbsorpSlot " + ToPercentage(stats[AccessoryPhyAbsorpSlot]));</p><p> Console.WriteLine("Accessory : AccessoryMagAbsorpSlot " + ToPercentage(stats[AccessoryMagAbsorpSlot]));</p><p> break;</p><p> case 6:</p><p> //Equip</p><p> //NOTE this can also be a shield !</p><p> Console.WriteLine("equip : ArmorPhyDefSlot " + ToPercentage(stats[ArmorPhyDefSlot]));</p><p> Console.WriteLine("equip : ArmorMagDefSlot " + ToPercentage(stats[ArmorMagDefSlot]));</p><p> Console.WriteLine("equip : ArmorDurabilitySlot " + ToPercentage(stats[ArmorDurabilitySlot]));</p><p> Console.WriteLine("equip : ArmorEvasionRatioSlot " + ToPercentage(stats[ArmorEvasionRatioSlot]));</p><p> Console.WriteLine("equip : ArmorPhySpecSlot " + ToPercentage(stats[ArmorPhySpecSlot]));</p><p> Console.WriteLine("equip : ArmorMagSpecSlot " + ToPercentage(stats[ArmorMagSpecSlot]));</p><p> break;</p><p> case 7:</p><p> //Weapon</p><p> Console.WriteLine("Weapon : WeaponPhyDmgSlot " + ToPercentage(stats[WeaponPhyDmgSlot]));</p><p> Console.WriteLine("Weapon : WeaponMagDmgSlot " + ToPercentage(stats[WeaponMagDmgSlot]));</p><p> Console.WriteLine("Weapon : WeaponDurabilitySlot " + ToPercentage(stats[WeaponDurabilitySlot]));</p><p> Console.WriteLine("Weapon : WeaponHitRatioSlot " + ToPercentage(stats[WeaponHitRatioSlot]));</p><p> Console.WriteLine("Weapon : WeaponCritSlot " + ToPercentage(stats[WeaponCritSlot]));</p><p> Console.WriteLine("Weapon : WeaponPhySpecSlot " + ToPercentage(stats[WeaponPhySpecSlot]));</p><p> Console.WriteLine("Weapon : WeaponMagSpecSlot " + ToPercentage(stats[WeaponMagSpecSlot]));</p><p> break;</p><p> default:</p><p> Console.WriteLine("{0} stats... wtf?", stats.Count);</p><p> break;</p><p> }</p><p> }</p><p></p><p> private static string ToPercentage(byte stat)</p><p> {</p><p> return String.Format("{0}%", stat * 100 / 31);</p><p> }</p><p> }</p><p>}</p><p>[/CODE]</p><p>The result when i start it is here :</p><p></p><p><img src="http://astucesa2balles.com/upload/download.php?file=1475171435.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p>I need the same code/result in php.</p><p>I already convert most of this code to php but the part i show....</p><p></p><p></p><p>That my actual php code with the missing part</p><p></p><p>[PHP]<?php</p><p> $ShieldDurabilitySlot = 0;</p><p> $ShieldPhySpecSlot = 1;</p><p> $ShieldMagSpecSlot = 2;</p><p> $ShieldBlockRatioSlot = 3;</p><p> $ShieldPhyDefSlot = 4;</p><p> $ShieldMagDefSlot = 5;</p><p></p><p> $ArmorDurabilitySlot = 0;</p><p> $ArmorPhySpecSlot = 1;</p><p> $ArmorMagSpecSlot = 2;</p><p> $ArmorPhyDefSlot = 3;</p><p> $ArmorMagDefSlot = 4;</p><p> $ArmorEvasionRatioSlot = 5;</p><p></p><p> $WeaponDurabilitySlot = 0;</p><p> $WeaponPhySpecSlot = 1;</p><p> $WeaponMagSpecSlot = 2;</p><p> $WeaponHitRatioSlot = 3;</p><p> $WeaponPhyDmgSlot = 4;</p><p> $WeaponMagDmgSlot = 5;</p><p> $WeaponCritSlot = 6;</p><p></p><p> $AccessoryPhyAbsorpSlot = 0;</p><p> $AccessoryMagAbsorpSlot = 1;</p><p></p><p> $variance = 20401094656;</p><p> DisplayVariance($variance);</p><p></p><p> function DisplayVariance($variance)</p><p> {</p><p> $stats = array();</p><p></p><p> echo "Variance : ".$variance;</p><p> while ($variance > 0)</p><p> {</p><p> $stat = ($variance & 31);</p><p> $variance >>= 5;</p><p></p><p> $stats[] = $stat;</p><p> }</p><p> for($i = 0; $i < count($stats); $i++)</p><p> switch($stats[$i])</p><p> {</p><p> case 2:</p><p> //Accessory</p><p> echo "Accessory : AccessoryPhyAbsorpSlot ".ToPercentage($stats[$AccessoryPhyAbsorpSlot]);</p><p> echo "Accessory : AccessoryMagAbsorpSlot ".ToPercentage($stats[$AccessoryMagAbsorpSlot]);</p><p> break;</p><p> case 6:</p><p> //Equip</p><p> //NOTE this can also be a shield !</p><p> echo "equip : ArmorPhyDefSlot " + ToPercentage($stats[$ArmorPhyDefSlot]);</p><p> echo "equip : ArmorMagDefSlot " + ToPercentage($stats[$ArmorMagDefSlot]);</p><p> echo "equip : ArmorDurabilitySlot " + ToPercentage($stats[$ArmorDurabilitySlot]);</p><p> echo "equip : ArmorEvasionRatioSlot " + ToPercentage($stats[$ArmorEvasionRatioSlot]);</p><p> echo "equip : ArmorPhySpecSlot " + ToPercentage($stats[$ArmorPhySpecSlot]);</p><p> echo "equip : ArmorMagSpecSlot " + ToPercentage($stats[$ArmorMagSpecSlot]);</p><p> break;</p><p> case 7:</p><p> //Weapon</p><p> echo "Weapon : WeaponPhyDmgSlot " + ToPercentage($stats[$WeaponPhyDmgSlot]);</p><p> echo "Weapon : WeaponMagDmgSlot " + ToPercentage($stats[$WeaponMagDmgSlot]);</p><p> echo "Weapon : WeaponDurabilitySlot " + ToPercentage($stats[$WeaponDurabilitySlot]);</p><p> echo "Weapon : WeaponHitRatioSlot " + ToPercentage($stats[$WeaponHitRatioSlot]);</p><p> echo "Weapon : WeaponCritSlot " + ToPercentage($stats[$WeaponCritSlot]);</p><p> echo "Weapon : WeaponPhySpecSlot " + ToPercentage($stats[$WeaponPhySpecSlot]);</p><p> echo "Weapon : WeaponMagSpecSlot " + ToPercentage($stats[$WeaponMagSpecSlot]);</p><p> break;</p><p> default:</p><p> echo $stats[$i]." stats... wtf?";</p><p> break;</p><p> }</p><p> }</p><p></p><p> function ToPercentage($stat)</p><p> {</p><p> return ($stat * 100 / 31).'%';</p><p> }</p><p>[/PHP]</p><p>[doublepost=1475178252,1475171520][/doublepost]Hello,</p><p></p><p>I reply to this topic because a friend solved the problem, it was from outdated php version.</p><p></p><p>Thanks anyway for your help.</p></blockquote><p></p>
[QUOTE="sami37, post: 385194, member: 71475"] Thanks for reply, Here is the fully program [CODE]using System; using System.Collections.Generic; namespace ConsoleApplication1 { class Program { private const byte ShieldDurabilitySlot = 0, ShieldPhySpecSlot = 1, ShieldMagSpecSlot = 2, ShieldBlockRatioSlot = 3, ShieldPhyDefSlot = 4, ShieldMagDefSlot = 5; private const byte ArmorDurabilitySlot = 0, ArmorPhySpecSlot = 1, ArmorMagSpecSlot = 2, ArmorPhyDefSlot = 3, ArmorMagDefSlot = 4, ArmorEvasionRatioSlot = 5; private const byte WeaponDurabilitySlot = 0, WeaponPhySpecSlot = 1, WeaponMagSpecSlot = 2, WeaponHitRatioSlot = 3, WeaponPhyDmgSlot = 4, WeaponMagDmgSlot = 5, WeaponCritSlot = 6; private const byte AccessoryPhyAbsorpSlot = 0, AccessoryMagAbsorpSlot = 1; static void Main() { const ulong variance = 20401094656; DisplayVariance(variance); Console.ReadLine(); } static void DisplayVariance(ulong variance) { var stats = new List<byte>(); Console.WriteLine("Variance : " + variance); while (variance > 0) { var stat = (byte)(variance & 0x1f); variance >>= 5; stats.Add(stat); } switch (stats.Count) { case 2: //Accessory Console.WriteLine("Accessory : AccessoryPhyAbsorpSlot " + ToPercentage(stats[AccessoryPhyAbsorpSlot])); Console.WriteLine("Accessory : AccessoryMagAbsorpSlot " + ToPercentage(stats[AccessoryMagAbsorpSlot])); break; case 6: //Equip //NOTE this can also be a shield ! Console.WriteLine("equip : ArmorPhyDefSlot " + ToPercentage(stats[ArmorPhyDefSlot])); Console.WriteLine("equip : ArmorMagDefSlot " + ToPercentage(stats[ArmorMagDefSlot])); Console.WriteLine("equip : ArmorDurabilitySlot " + ToPercentage(stats[ArmorDurabilitySlot])); Console.WriteLine("equip : ArmorEvasionRatioSlot " + ToPercentage(stats[ArmorEvasionRatioSlot])); Console.WriteLine("equip : ArmorPhySpecSlot " + ToPercentage(stats[ArmorPhySpecSlot])); Console.WriteLine("equip : ArmorMagSpecSlot " + ToPercentage(stats[ArmorMagSpecSlot])); break; case 7: //Weapon Console.WriteLine("Weapon : WeaponPhyDmgSlot " + ToPercentage(stats[WeaponPhyDmgSlot])); Console.WriteLine("Weapon : WeaponMagDmgSlot " + ToPercentage(stats[WeaponMagDmgSlot])); Console.WriteLine("Weapon : WeaponDurabilitySlot " + ToPercentage(stats[WeaponDurabilitySlot])); Console.WriteLine("Weapon : WeaponHitRatioSlot " + ToPercentage(stats[WeaponHitRatioSlot])); Console.WriteLine("Weapon : WeaponCritSlot " + ToPercentage(stats[WeaponCritSlot])); Console.WriteLine("Weapon : WeaponPhySpecSlot " + ToPercentage(stats[WeaponPhySpecSlot])); Console.WriteLine("Weapon : WeaponMagSpecSlot " + ToPercentage(stats[WeaponMagSpecSlot])); break; default: Console.WriteLine("{0} stats... wtf?", stats.Count); break; } } private static string ToPercentage(byte stat) { return String.Format("{0}%", stat * 100 / 31); } } } [/CODE] The result when i start it is here : [IMG]http://astucesa2balles.com/upload/download.php?file=1475171435.png[/IMG] I need the same code/result in php. I already convert most of this code to php but the part i show.... That my actual php code with the missing part [PHP]<?php $ShieldDurabilitySlot = 0; $ShieldPhySpecSlot = 1; $ShieldMagSpecSlot = 2; $ShieldBlockRatioSlot = 3; $ShieldPhyDefSlot = 4; $ShieldMagDefSlot = 5; $ArmorDurabilitySlot = 0; $ArmorPhySpecSlot = 1; $ArmorMagSpecSlot = 2; $ArmorPhyDefSlot = 3; $ArmorMagDefSlot = 4; $ArmorEvasionRatioSlot = 5; $WeaponDurabilitySlot = 0; $WeaponPhySpecSlot = 1; $WeaponMagSpecSlot = 2; $WeaponHitRatioSlot = 3; $WeaponPhyDmgSlot = 4; $WeaponMagDmgSlot = 5; $WeaponCritSlot = 6; $AccessoryPhyAbsorpSlot = 0; $AccessoryMagAbsorpSlot = 1; $variance = 20401094656; DisplayVariance($variance); function DisplayVariance($variance) { $stats = array(); echo "Variance : ".$variance; while ($variance > 0) { $stat = ($variance & 31); $variance >>= 5; $stats[] = $stat; } for($i = 0; $i < count($stats); $i++) switch($stats[$i]) { case 2: //Accessory echo "Accessory : AccessoryPhyAbsorpSlot ".ToPercentage($stats[$AccessoryPhyAbsorpSlot]); echo "Accessory : AccessoryMagAbsorpSlot ".ToPercentage($stats[$AccessoryMagAbsorpSlot]); break; case 6: //Equip //NOTE this can also be a shield ! echo "equip : ArmorPhyDefSlot " + ToPercentage($stats[$ArmorPhyDefSlot]); echo "equip : ArmorMagDefSlot " + ToPercentage($stats[$ArmorMagDefSlot]); echo "equip : ArmorDurabilitySlot " + ToPercentage($stats[$ArmorDurabilitySlot]); echo "equip : ArmorEvasionRatioSlot " + ToPercentage($stats[$ArmorEvasionRatioSlot]); echo "equip : ArmorPhySpecSlot " + ToPercentage($stats[$ArmorPhySpecSlot]); echo "equip : ArmorMagSpecSlot " + ToPercentage($stats[$ArmorMagSpecSlot]); break; case 7: //Weapon echo "Weapon : WeaponPhyDmgSlot " + ToPercentage($stats[$WeaponPhyDmgSlot]); echo "Weapon : WeaponMagDmgSlot " + ToPercentage($stats[$WeaponMagDmgSlot]); echo "Weapon : WeaponDurabilitySlot " + ToPercentage($stats[$WeaponDurabilitySlot]); echo "Weapon : WeaponHitRatioSlot " + ToPercentage($stats[$WeaponHitRatioSlot]); echo "Weapon : WeaponCritSlot " + ToPercentage($stats[$WeaponCritSlot]); echo "Weapon : WeaponPhySpecSlot " + ToPercentage($stats[$WeaponPhySpecSlot]); echo "Weapon : WeaponMagSpecSlot " + ToPercentage($stats[$WeaponMagSpecSlot]); break; default: echo $stats[$i]." stats... wtf?"; break; } } function ToPercentage($stat) { return ($stat * 100 / 31).'%'; } [/PHP] [doublepost=1475178252,1475171520][/doublepost]Hello, I reply to this topic because a friend solved the problem, it was from outdated php version. Thanks anyway for your help. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
Convert c# to php
Top