Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.95 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using GryKarciane.Models;
  7. using GryKarciane.Services;
  8. using System.IO;
  9.  
  10. namespace GryKarciane.Controllers
  11. {
  12.     public class WarController : Controller
  13.     {
  14.         [Route("War/")]
  15.         public ActionResult Index()
  16.         {
  17.             List<Karta> talia = new List<Karta>();
  18.             List<Karta> taliatransformation = new List<Karta>();
  19.             List<int> Rex = new List<int>();
  20.            
  21.  
  22.  
  23.             Talia sztos = new Talia();
  24.            
  25.            
  26.  
  27.  
  28.             Karta nowa = new Karta();
  29.             talia = sztos.talia;
  30.             taliatransformation = sztos.talia;
  31.  
  32.        
  33.              
  34.             // Losowanie kart
  35.  
  36.             Rex = Functions.Losowanie(52, 52);
  37.      
  38.             for(int i=0; i< Rex.Count ; i++)
  39.             {
  40.                     taliatransformation[i] = talia[Rex[i]];  
  41.             }
  42.          
  43.        
  44.  
  45.             List<Karta>  playerdeck = new List<Karta>();
  46.             List<Karta> computerdeck = new List<Karta>();
  47.             List<string> fff = new List<string>();
  48.  
  49.            
  50.  
  51.             playerdeck = taliatransformation.GetRange(25, 26);
  52.             computerdeck = taliatransformation.GetRange(25, 26);
  53.  
  54.  
  55.  
  56.             // Dzielenie Kart na 2 kupki
  57.             int index = 0;
  58.             for(int i=0; i < Rex.Count; i++)
  59.             {
  60.                 if(i<=25)
  61.                 {
  62.                     playerdeck[i] = taliatransformation[i];
  63.                 }
  64.                 if(i>25)
  65.                 {
  66.                     computerdeck[index] = taliatransformation[i];
  67.                      index++;
  68.                 }
  69.              }
  70.  
  71.  
  72.             var viewModel = new MyViewModel();
  73.  
  74.             viewModel.ListA = playerdeck;
  75.             viewModel.ListB = computerdeck;
  76.  
  77.             // Zapisywanie do pliku
  78.  
  79.             string[] t = new string[playerdeck.Count];
  80.             string[] v = new string[playerdeck.Count];
  81.  
  82.             for (int i = 0; i < playerdeck.Count; i++)
  83.             {
  84.                 t[i] = playerdeck[i].ReturnString();
  85.                 v[i] = computerdeck[i].ReturnString();
  86.             }
  87.  
  88.  
  89.             System.IO.File.WriteAllLines(@"playerdeck.txt", t);
  90.             System.IO.File.WriteAllLines(@"computerdeck.txt", v);
  91.  
  92.             string[] vy = new string[playerdeck.Count];
  93.  
  94.             string[] playerdeckF = System.IO.File.ReadAllLines(@"playerdeck.txt");
  95.             string[] computerdeckG = System.IO.File.ReadAllLines(@"computerdeck.txt");
  96.  
  97.          
  98.            
  99.             int[] playerdeckindex = new int[playerdeck.Count];
  100.             int[] computerdeckindex = new int[playerdeck.Count];
  101.  
  102.             for (int i = 0; i < playerdeck.Count; i++)
  103.             {
  104.                 playerdeckindex[i] = Int32.Parse(playerdeckF[i]);
  105.                 computerdeckindex[i] = Int32.Parse(computerdeckG[i]);  
  106.             }
  107.  
  108.             Talia Helena = new Talia();
  109.             List<Karta> Uber = new List<Karta>();
  110.             List<Karta> Grazyna = new List<Karta>();
  111.  
  112.             Uber = playerdeck;
  113.             Grazyna = playerdeck;
  114.  
  115.             for (int i = 0; i < playerdeck.Count; i++)
  116.             {  
  117.                    int Index =  playerdeckindex[i];
  118.                    int Index2 = computerdeckindex[i];
  119.                    Uber[i] = Helena.talia[Index];
  120.                    Grazyna[i] = Helena.talia[Index2];
  121.             }
  122.  
  123.  
  124.             Console.WriteLine();
  125.             Console.WriteLine();
  126.             Console.WriteLine();
  127.            
  128.             return View(viewModel);
  129.         }
  130.  
  131.  
  132.  
  133.         [Route("War/")]
  134.         public ActionResult Play()
  135.         {
  136.             // odzyskanie tali w tablicy string
  137.             string[] playerdeck = System.IO.File.ReadAllLines(@"d:\x.txt");
  138.             string[] computerdeck = System.IO.File.ReadAllLines(@"d:\x.txt");
  139.  
  140.  
  141.  
  142.  
  143.             return View();
  144.         }
  145.  
  146.  
  147.     }
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement