r/PowerShell • • Jul 27 '19

Script Sharing 1-2 player strategy game, in powershell

Hey all, I made a video game in powershell and figured the people here might like it. It's free and open source, of course, and you can download it as a zip from here:

https://mediumcharlie.itch.io/arrrrg

(There is an option to donate but you should just skip that)

128 Upvotes

22 comments sorted by

11

u/nerfnuggets Jul 27 '19

Curious if this will work in Linux powershell?

10

u/mediumCharlie Jul 27 '19

Hey, sorry to spam you with replies but a modified Linux build is now available, but it's the text-only version with no ascii art or sound.

4

u/nerfnuggets Jul 27 '19

Np I'll check it out

9

u/mediumCharlie Jul 27 '19

Sadly it does not, from what I can tell (tried on Ubuntu 18.04). The base command line interface works (somewhat) but the ascii art and sound do not. I can make a text-only version for Linux in a couple minutes, but a full port would take some time.

7

u/mediumCharlie Jul 27 '19

I have no idea, but I'll try it out on a linux v.m. that I have and let you know.

4

u/northendtrooper Jul 27 '19

Curious does it work only on one machine or can it be played over a lan network? I Can't test until Monday.

4

u/mediumCharlie Jul 27 '19

Sorry, but it only works on one machine.

3

u/northendtrooper Jul 27 '19

Hmmm. Just spit balling here.

$share = machine or shared server.

Two machine run the ps1 code. Player 1 initiates it. Which creates a txt file on the $share. Where they append the txt on the $share.

Maybe a

 (while (player.txt).lastaccesstime -gt than (get-date).totalminutes){ Write-Host "Waiting for player to connect" -Foreground Red}

4

u/mediumCharlie Jul 27 '19

Very interesting, I'll make an attempt but I'm still pretty new to powershell (I used this project to learn it, actually) so no guarantees. You'll be the first to know if it works or not.

6

u/dopyrory3 Jul 27 '19

Alternatively, using the .NET HttpListener class for one machine to host a simple web server that takes input from the other players sessions would be a good learning experience.

Teaches some scaling principals, basic hax0r prevention fundamentals, and a new PowerShell challenge (bragging rights included)

3

u/AndemanMan Jul 28 '19

I was blasting away at the CPU-controlled ship for a few turns, but our guns weren't doing a lot of damage to each other. Fun concept though and I like the two-console UI and the ASCII art.

3

u/mediumCharlie Jul 28 '19

Hey thanks a ton for playing! Also, I'm not sure if I mentioned this in the tutorial or not, but the damage scales with the distance between the ships. If you want to do more damage to the bot, you can start a bit closer or sail in.

2

u/the_helpdesk Jul 27 '19

Without looking at the script, why does it require admin rights?

2

u/mediumCharlie Jul 27 '19

It needs to change the execution-policy to run.

10

u/keseykid Jul 27 '19

I would remove that and let people handle that on their own.. it’s a security mechanism after all

2

u/mediumCharlie Jul 27 '19

I would love to, but I'm not entirely sure how to run my custom script without changing the execution policy, would doing a temporary bypass at the start of the script work? Like this:

Set-ExecutionPolicy Bypass -scope Process

Thanks for the feedback

4

u/keseykid Jul 27 '19

on your own system you can solve it a number of ways. Change your default EP to remote signed or sign your script. when someone else uses your script, they will have to deal with it as they would any remote script. Since the point of an EP is to mitigate malicious, foreign code, attempting to subvert it in your script will be frowned upon.

3

u/mediumCharlie Jul 27 '19

Good to know. I do not change the EP from within my script, but I do give instructions on how to change the EP in the readme. I will make sure to avoid altering this value, and I also now understand a lot more as to what an EP is and how it protects people, thank you very much for the info.

1

u/evilsaltine Jul 28 '19

Create a batch file that runs your script with the option -ExecutionPolicy Bypass.

4

u/odroller Jul 28 '19

Execution Policy in PowerShell is not a security mechanism. It is trivial to bypass even as a non-admin user.

https://adsecurity.org/?p=1232

1

u/SirWobbyTheFirst Jul 27 '19

The Execution Policy can be set on a user or process basis. If you set it to user scope then it applies only to the current user and does not admin privileges to change.

1

u/mediumCharlie Jul 27 '19

That's good to hear, thanks. I did some digging and as it turns out it never required admin rights, it just defaulted to changing the execution policy for the user only (I think). Bottom line is that it works without an admin, I will update the information on the game's page with this new knowledge. Thanks again!