Skip to content

Commit

Permalink
add custom board
Browse files Browse the repository at this point in the history
  • Loading branch information
KejariwalAyush authored Jul 4, 2020
1 parent 1dd3fd6 commit 52807a3
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 115 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.flutter.plugins;

import androidx.annotation.Keep;
import androidx.annotation.NonNull;

import io.flutter.embedding.engine.FlutterEngine;

/**
* Generated file. Do not edit.
* This file is generated by the Flutter tool based on the
* plugins that support the Android platform.
*/
@Keep
public final class GeneratedPluginRegistrant {
public static void registerWith(@NonNull FlutterEngine flutterEngine) {
}
}
2 changes: 2 additions & 0 deletions android/local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sdk.dir=C:\\Users\\Sys Admin\\AppData\\Local\\Android\\sdk
flutter.sdk=C:\\src\\flutter
Binary file added assets/images/custom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions ios/Flutter/Generated.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// This is a generated file; do not edit or check into version control.
FLUTTER_ROOT=C:\src\flutter
FLUTTER_APPLICATION_PATH=E:\ayush\Snake-Ladder-master
FLUTTER_TARGET=lib\main.dart
FLUTTER_BUILD_DIR=build
SYMROOT=${SOURCE_ROOT}/../build\ios
OTHER_LDFLAGS=$(inherited) -framework Flutter
FLUTTER_FRAMEWORK_DIR=C:\src\flutter\bin\cache\artifacts\engine\ios
FLUTTER_BUILD_NAME=1.0.0
FLUTTER_BUILD_NUMBER=1
11 changes: 11 additions & 0 deletions ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
# This is a generated file; do not edit or check into version control.
export "FLUTTER_ROOT=C:\src\flutter"
export "FLUTTER_APPLICATION_PATH=E:\ayush\Snake-Ladder-master"
export "FLUTTER_TARGET=lib\main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build\ios"
export "OTHER_LDFLAGS=$(inherited) -framework Flutter"
export "FLUTTER_FRAMEWORK_DIR=C:\src\flutter\bin\cache\artifacts\engine\ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
17 changes: 17 additions & 0 deletions ios/Runner/GeneratedPluginRegistrant.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// Generated file. Do not edit.
//

#ifndef GeneratedPluginRegistrant_h
#define GeneratedPluginRegistrant_h

#import <Flutter/Flutter.h>

NS_ASSUME_NONNULL_BEGIN

@interface GeneratedPluginRegistrant : NSObject
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry;
@end

NS_ASSUME_NONNULL_END
#endif /* GeneratedPluginRegistrant_h */
12 changes: 12 additions & 0 deletions ios/Runner/GeneratedPluginRegistrant.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// Generated file. Do not edit.
//

#import "GeneratedPluginRegistrant.h"

@implementation GeneratedPluginRegistrant

+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
}

@end
179 changes: 64 additions & 115 deletions lib/MyHomePage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ class _MyHomePageState extends State<MyHomePage> {
bool plyturn = true;
bool isComputer = false;

int order(int n) {
if (n <= 10)
return 11 - n;
else if (n <= 30 && n > 20)
return 31 - n + 20;
else if (n <= 50 && n > 40)
return 51 - n + 40;
else if (n <= 70 && n > 60)
return 71 - n + 60;
else if (n <= 90 && n > 80)
return 91 - n + 80;
else
return n;
}

@override
Widget build(BuildContext context) {
return WillPopScope(
Expand Down Expand Up @@ -109,15 +124,10 @@ class _MyHomePageState extends State<MyHomePage> {
: index.isEven
? Color.fromRGBO(220, 200, 109, 1)
: Color.fromRGBO(39, 25, 60, 1),
child: Hero(
tag: ply1 == 100 - index
? 'ply1'
: ply2 == 100 - index ? 'ply2' : 'None',
child: Text(
' ${100 - index}',
style: TextStyle(
fontSize: 10, color: Colors.white),
),
child: Text(
' ${order(100 - index)}',
style: TextStyle(
fontSize: 10, color: Colors.white),
),
);
}),
Expand All @@ -127,7 +137,7 @@ class _MyHomePageState extends State<MyHomePage> {
padding: EdgeInsets.all(2),
alignment: Alignment.topLeft,
child: Image.asset(
'assets/images/board.png',
'assets/images/custom.png',
fit: BoxFit.cover,
),
),
Expand Down Expand Up @@ -257,43 +267,10 @@ class _MyHomePageState extends State<MyHomePage> {
? randomNo == 1 ? ply2 = randomNo : ply2 = 0
: ply2 + randomNo > 100
? ply2 = ply2
: ply2 = ply2 + randomNo;
: ply2 = order(ply2 + randomNo);
Future.delayed(Duration(seconds: 1)).whenComplete(() {
setState(() {
switch (ply2) {
case 17:
ply2 = 6;
break;
case 33:
ply2 = 14;
break;
case 39:
ply2 = 28;
break;
case 54:
ply2 = 46;
break;
case 81:
ply2 = 43;
break;
case 99:
ply2 = 18;
break;

case 84:
ply2 = 95;
break;
case 47:
ply2 = 86;
break;
case 50:
ply2 = 59;
break;
case 2:
ply2 = 43;
break;
default:
}
ply2 = snakeLadderCmd(ply2);
});
});
if (ply2 == 100)
Expand Down Expand Up @@ -344,43 +321,10 @@ class _MyHomePageState extends State<MyHomePage> {
? randomNo == 1 ? ply1 = randomNo : ply1 = 0
: ply1 + randomNo > 100
? ply1 = ply1
: ply1 = ply1 + randomNo;
: ply1 = order(ply1 + randomNo);
Future.delayed(Duration(seconds: 1)).whenComplete(() {
setState(() {
switch (ply1) {
case 17:
ply1 = 6;
break;
case 33:
ply1 = 14;
break;
case 39:
ply1 = 28;
break;
case 54:
ply1 = 46;
break;
case 81:
ply1 = 43;
break;
case 99:
ply1 = 18;
break;

case 84:
ply1 = 95;
break;
case 47:
ply1 = 86;
break;
case 50:
ply1 = 59;
break;
case 2:
ply1 = 43;
break;
default:
}
ply1 = snakeLadderCmd(ply1);
});
});
if (ply1 == 100)
Expand Down Expand Up @@ -450,6 +394,44 @@ class _MyHomePageState extends State<MyHomePage> {
);
}

int snakeLadderCmd(int ply) {
switch (ply) {
case 17:
ply = 6;
break;
case 33:
ply = 14;
break;
case 39:
ply = 28;
break;
case 54:
ply = 46;
break;
case 81:
ply = 43;
break;
case 99:
ply = 18;
break;

case 84:
ply = 95;
break;
case 47:
ply = 86;
break;
case 50:
ply = 59;
break;
case 2:
ply = 43;
break;
default:
}
return ply;
}

InkWell player1(BuildContext context) {
return InkWell(
onTap: () {
Expand All @@ -465,43 +447,10 @@ class _MyHomePageState extends State<MyHomePage> {
? randomNo == 1 ? ply1 = randomNo : ply1 = 0
: ply1 + randomNo > 100
? ply1 = ply1
: ply1 = ply1 + randomNo;
: ply1 = order(ply1 + randomNo);
Future.delayed(Duration(seconds: 1)).whenComplete(() {
setState(() {
switch (ply1) {
case 17:
ply1 = 6;
break;
case 33:
ply1 = 14;
break;
case 39:
ply1 = 28;
break;
case 54:
ply1 = 46;
break;
case 81:
ply1 = 43;
break;
case 99:
ply1 = 18;
break;

case 84:
ply1 = 95;
break;
case 47:
ply1 = 86;
break;
case 50:
ply1 = 59;
break;
case 2:
ply1 = 43;
break;
default:
}
ply1 = snakeLadderCmd(ply1);
});
});
if (ply1 == 100)
Expand Down

0 comments on commit 52807a3

Please sign in to comment.