Created
February 3, 2014 05:01
-
-
Save meyea/8779065 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sing System; | |
using PortableLeagueAPI; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.Linq; | |
using System.Reflection; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Windows.Forms; | |
//Known errors: Riot's API is unstable in the new season. If it returns an error (ex. 404) the program will try to ignore the returned error, but it can fail the error check. | |
namespace lolCompare_vform_ //Main namespace. No inheritance required. | |
{ | |
public partial class formSummoners : Form | |
{ | |
//var decs | |
static string summoner1Name; //Need to convert to Summoner ID | |
static string summoner2Name; //Need to convert to Summoner ID | |
static int summoner1ID; //converted int | |
static int summoner2ID; //converted int | |
static int? summoner1Tier; | |
static int? summoner2Tier; | |
static long ID11; | |
static long ID22; | |
static bool sum1done; | |
static bool sum2done; | |
// end of var decs | |
public formSummoners() //initialize forms component | |
{ | |
InitializeComponent(); | |
} | |
private void Form1_Load(object sender, EventArgs e) //Function for when the program starts | |
{ | |
} | |
private void fightClick(object sender, EventArgs e) //Start the comparison on "FIGHT" click | |
{ | |
S2ID.summonertoID(); | |
Calculations.Tiers(); | |
//Calculations.Compare(); | |
} | |
private void summ1Entered(object sender, EventArgs e) //Text in summ1Text Changed | |
{ | |
summoner1Name = (summ1Text.Text); | |
} | |
private void summ2Entered(object sender, EventArgs e) //Text in summ2Text Changed | |
{ | |
summoner2Name = (summ2Text.Text); | |
} | |
// non-user generated functions | |
public class S2ID | |
{ | |
public static void summonertoID() | |
{ | |
var ID1 = EF.RiotApi.Client.RiotWeb.API.Summoner.GetSummoner(summoner1Name); | |
ID11 = ID1.Id; | |
summoner1ID = unchecked((int)ID1.Id); | |
var ID2 = EF.RiotApi.Client.RiotWeb.API.Summoner.GetSummoner(summoner2Name); | |
ID22 = ID2.Id; | |
summoner2ID = unchecked((int)ID2.Id); | |
} | |
} | |
public class Calculations | |
{ | |
public static void Tiers() //gets the league tier ranking | |
{ | |
while(sum1done == false) | |
{ | |
var leagues = EF.RiotApi.Client.API.LeagueApi.Instance.GetLeagueBySummonerAsync(ID11).Result; | |
foreach (var league in leagues) | |
{ | |
var summoner1LeagueVar = league.Value; | |
if (summoner1LeagueVar.Tier.Contains("BRONZE")) | |
{ | |
summoner1Tier = 1; | |
} | |
else if (summoner1LeagueVar.Tier.Contains("SILVER")) | |
{ | |
summoner1Tier = 2; | |
} | |
else if (summoner1LeagueVar.Tier.Contains("GOLD")) | |
{ | |
summoner1Tier = 3; | |
} | |
else if (summoner1LeagueVar.Tier.Contains("PLATINUM")) | |
{ | |
summoner1Tier = 4; | |
} | |
else if (summoner1LeagueVar.Tier.Contains("DIAMOND")) | |
{ | |
summoner1Tier = 5; | |
} | |
else if (summoner1LeagueVar.Tier.Contains("CHALLENGER")) | |
{ | |
summoner1Tier = 6; | |
} | |
MessageBox.Show("sum1done"); | |
} | |
sum1done = true; | |
} | |
while(sum2done == false) | |
{ | |
var leagues = EF.RiotApi.Client.API.LeagueApi.Instance.GetLeagueBySummonerAsync(ID22).Result; | |
foreach (var league in leagues) | |
{ | |
var summoner2LeagueVar = league.Value; | |
if(summoner2LeagueVar.Tier.Contains("BRONZE")) | |
{ | |
summoner2Tier = 1; | |
} | |
if(summoner2LeagueVar.Tier.Contains("SILVER")) | |
{ | |
summoner2Tier = 2; | |
} | |
if(summoner2LeagueVar.Tier.Contains("GOLD")) | |
{ | |
summoner2Tier = 3; | |
} | |
if(summoner2LeagueVar.Tier.Contains("PLATINUM")) | |
{ | |
summoner2Tier = 4; | |
} | |
if(summoner2LeagueVar.Tier.Contains("DIAMOND")) | |
{ | |
summoner2Tier = 5; | |
} | |
if(summoner2LeagueVar.Tier.Contains("CHALLENGER")) | |
{ | |
summoner2Tier = 6; | |
} | |
} | |
sum2done = true; | |
} | |
} | |
public static void KDAstats()// gets kills/deaths/assists | |
{ | |
} | |
public static void Compare()// | |
{ | |
if(summoner1Tier > summoner2Tier) | |
{ | |
MessageBox.Show(summoner1Name, " wins"); | |
} | |
else | |
{ | |
MessageBox.Show(summoner2Name, " wins"); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment