Terminal Game. Black and White have only pawns. White wins if their pawn moved to 8th line. Black wins if their pawn moves to 1st line. If black or white haven't any move, then no one wins(stalemate))

Overview

Only-Pawns-Chess

Terminal game for 2 players
Regular chess but all sides have only pawns

Rules

This game extend all the rules of regular chess but it has one more rule:

  • If pawn of some side is on last line, then that side is winner!

Snippets of code

This class is used for count pawns on the board

 enum class Pawns(val color: String, var left: Int) {
    WHITE("White", 8),
    BLACK("Black", 8);

    fun beat() {
        left--
    }
 }
 

This snippet of code used to create board

val boldLine = "  +---+---+---+---+---+---+---+---+"
val filesLine = "    a   b   c   d   e   f   g   h"
val files = "abcdefgh"
val regex = """[a-h][1-8][a-h][1-8]\b""".toRegex()
val blackPlayer = "| B "
val whitePlayer = "| W "
var chosenPlayer = whitePlayer
val emptySlot = "|   "
val blackPlayerStartingIndex = 7
val whitePlayerStartingIndex = 2
var invalidInput = false
var whitePassant = false
var blackPassant = false
var currentCoords = ""
//chessboard initialization
val chessboard = mutableListOf(
    MutableList(8) { "|   " }, //8
    MutableList(8) { blackPlayer },//7
    MutableList(8) { "|   " }, //6
    MutableList(8) { "|   " }, //5
    MutableList(8) { "|   " }, //4
    MutableList(8) { "|   " }, //3
    MutableList(8) { whitePlayer }, //2
    MutableList(8) { "|   " } //1
).reversed()

This is start of the game

println(" Pawns-Only Chess")
println("First Player's name: ")
val player1 = readLine()!!
println("Second Player's name: ")
val player2 = readLine()!!
var currentTurn = player1

This is printing result of the game

{ currentTurn = "exit" println("White wins!") println("Bye!") } "P2" -> { currentTurn = "exit" println("Black wins!") println("Bye!") } else -> { currentTurn = "exit" println("Stalemate!") println("Bye!") } } } ">
fun ending(res: String) {
    printBoard()
    when (res) {
        "P1" -> {
            currentTurn = "exit"
            println("White wins!")
            println("Bye!")
        }
        "P2" -> {
            currentTurn = "exit"
            println("Black wins!")
            println("Bye!")
        }
        else -> {
            currentTurn = "exit"
            println("Stalemate!")
            println("Bye!")
        }
    }
}
You might also like...
Multiplayer Dots and Boxes game for Android

Multiplayer Dots and Boxes game for Android. One player is the server, and the rest connect to them. Has player customization and in-game chat! Still in development, but fully compatible with version 2.0 of my NetDot protocol.

An easy open source Android Native Game FrameWork.
An easy open source Android Native Game FrameWork.

JustWeEngine - Android Game FrameWork An easy open source Android Native Game FrameWork. Engine Flow Chart How To Use? Import Engine's module as Libra

Desktop/Android/HTML5/iOS Java game development framework
Desktop/Android/HTML5/iOS Java game development framework

Cross-platform Game Development Framework libGDX is a cross-platform Java game development framework based on OpenGL (ES) that works on Windows, Linux

Cocos2d-x is a suite of open-source, cross-platform, game-development tools used by millions of developers all over the world.
Cocos2d-x is a suite of open-source, cross-platform, game-development tools used by millions of developers all over the world.

cocos2d-x Win32 Others cocos2d-x is a multi-platform framework for building 2d games, interactive books, demos and other graphical applications. It is

Free Android 2D OpenGL Game Engine

AndEngine Donations While developing AndEngine was a lot of fun, it also also consumed many(!) months of my life. It actually continues to cost me a s

A cross-platform Java game Engine (Framework) , support JavaFX / Android / IOS / HTML5 / Linux / MAC / Windows
A cross-platform Java game Engine (Framework) , support JavaFX / Android / IOS / HTML5 / Linux / MAC / Windows

Loon Game Engine (Java Game Framework) EN / KR Free Game Resources Links Download Loon Game Engine Only Android-studio Template : androidstudio-templa

Cocos2d-x is a suite of open-source, cross-platform, game-development tools used by millions of developers all over the world.
Cocos2d-x is a suite of open-source, cross-platform, game-development tools used by millions of developers all over the world.

cocos2d-x Win32 Others cocos2d-x is a multi-platform framework for building 2d games, interactive books, demos and other graphical applications. It is

QRGame - storage a game inside a qr code
QRGame - storage a game inside a qr code

QRGame Can we storage a game inside a qr code? Yes! At least in theory. That was the question that started that entire project. QRGame is an Android p

Experimental multiplayer game
Experimental multiplayer game

Enjoy retro games? Enjoy multiplayer games? Ever wanted to play one retro game against a different game in real time?

Owner
Pavel Levchenko
Pavel Levchenko
A first-person shooter game where the only things you'll hear are your own thoughts.

Bloody Silence This is a shooter unlike any you have ever played. There is no sound whatsoever, so you will need to use your eyesight to find indicato

Liz Ainslie 4 Oct 23, 2022
Cities is a popular game in which each player takes turns naming a city in any country, starting with a letter that ends with the name of the previous city.

Game Cities Example Download Download the latest version of the Android app from this link. Building Using Android Studio Clone the repo, open it in A

Dmitry Savin 1 Mar 13, 2022
Tapping-Game - Following the random instruction one has to tap the correct ball or balloon with correct text on it

Tapping-Game A simple game where a player has to follow the random instruction a

Manish 1 Jan 18, 2022
Game made with Korge (Kotlin Multiplatform game engine)

MolesAttack Kotlin Multiplatform Game Play Html/js: https://feliperce.github.io/MolesAttack-Distribution/ Jar: https://feliperce.github.io/MolesAttack

Felipe Rodrigues 10 May 30, 2022
Our maze game is an 2d-animation game developed using android studio.

Our maze game is an 2d-animation game developed using android studio. The game consists of a ball and a board with a hole in the center of it. We are using accelerometer as controller to guide ball towards the hole. T

Suraj Devgan 6 Nov 29, 2022
simple game implements with kotlin and jetpack.(covered by unit test)

Simple Spy Game: Source Code ?? Published version ?? This repository contains a detailed game app that implements simple game using Koin, Room, Corout

Reza Darvishian 11 Jul 2, 2022
Spooky house game with monsters and sounds

SHGWMAS Spooky house game with monsters and sounds INSTRUCTIONS to play the game you must: have a brain downloaded the world + jar from the releases t

Team RickRoll 8 Oct 30, 2021
Tic Tac Toe is a two-player game in which the objective is to take turns and mark the correct spaces in a 3x3 (or larger) grid

Tic Tac Toe is a two-player game in which the objective is to take turns and mark the correct spaces in a 3x3 (or larger) grid.

Sylwia 2 Feb 26, 2022
Butterfly - Small and powerful weapons, own it, let your Android are developed like Tiger, Carry whole game!

Butterfly - Small and powerful weapons, own it, let your Android are developed like Tiger, Carry whole game!

Season 114 Dec 26, 2022
A Ktor-based server that handles game process, user registration and packs provision

Polyhoot! Server backend A Ktor-based server that handles game process, user registration and packs provision Deploying server locally You can deploy

Polyhoot! 2 May 31, 2022