DEV Community

Kien Nguyen Chi
Kien Nguyen Chi

Posted on

2 1

OSD600 - Week 5 - Release 0.2 - Hacktoberfest

Introduction

This week, I start my Release 0.2 Project by working on Hacktoberfest. After few hours or I can say half of a day, scrolling hundreds of projects on Hacktoberfest, I finally find one that interests me. The project is A Discord-Bot to play Werewolf with your friends.

My Issue

The program is written in Rust - language that I haven't used before. I take me a lot of time to read the code and read about Rust syntax to understand how it works. Although this new thing is unfamiliar with me, I still want to give it a try.

Issue Explanation

In the current program, the Bot allows you to start a game round with 0 Players and 0 Roles, which should not happen because it does not make any sense at all.

Working Process

After the step of initializing players for the round, I implement the code to figure out if there is a player or not. If there is more than player, the program will start the round. Otherwise, it will display an appropriate message. The owner supports me a lot to understand how the structure of the program is, so I can implement my code in an appropriate location. Also, the owner supports me about Rust syntax, which I'm not yet familiar.

After finishing everything supposed to work, the owner realizes the string type in Rust does not implement the std::error::Error (for the program to display error message). So we simply create new type of StringError converting string to make the it usable for Rust Error type.

let playerCount: usize = source.state.participants.len();
if playerCount < 1{
      return Err(TransitionError::new(StringError("Cannot start the game with no player".to_string())));
}
Enter fullscreen mode Exit fullscreen mode

Experiences

Overall, in order to implement few lines of code, I have to spend a lot of time to read how the Rust language works. This is also a new interesting experience for me to work in a language that I have never done before.

The owner of the repo is very nice. He replies me so quickly whenever I have a question or there is a typo needed to be fixed in my code.

I am very happy that I worked in a project like this. If you are interesting in this project, please take a look at the links provided below.

Links

Owner's Repository: Original Repo
My Repository: My Repo
My Issue: Issue #4
My Pull Request: PR #13

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay